Class: ConvenientService::Examples::Standard::Gemfile::Services::PrintShellCommand
- Inherits:
-
Object
- Object
- ConvenientService::Examples::Standard::Gemfile::Services::PrintShellCommand
- Includes:
- Service::Configs::Standard
- Defined in:
- lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#skip ⇒ Object
readonly
Returns the value of attribute skip.
Instance Method Summary collapse
- #fallback_result ⇒ Object
-
#initialize(command:, skip: false, out: $stdout) ⇒ PrintShellCommand
constructor
A new instance of PrintShellCommand.
- #result ⇒ Object
Methods included from Service::Configs::Standard
Methods included from Config
Constructor Details
#initialize(command:, skip: false, out: $stdout) ⇒ PrintShellCommand
Returns a new instance of PrintShellCommand.
23 24 25 26 27 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 23 def initialize(command:, skip: false, out: $stdout) @command = command @skip = skip @out = out end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
21 22 23 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 21 def command @command end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
21 22 23 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 21 def out @out end |
#skip ⇒ Object (readonly)
Returns the value of attribute skip.
21 22 23 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 21 def skip @skip end |
Instance Method Details
#fallback_result ⇒ Object
42 43 44 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 42 def fallback_result success end |
#result ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 29 def result return error("Command is `nil`") if command.nil? return error("Command is empty?") if command.empty? return failure("Printing of shell command `#{command}` is skipped") if skip out.puts out.puts ::Paint["$ #{command}", :blue, :bold] success end |