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
Constructor Details
#initialize(command:, skip: false, out: $stdout) ⇒ PrintShellCommand
Returns a new instance of PrintShellCommand.
18 19 20 21 22 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 18 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.
16 17 18 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 16 def command @command end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
16 17 18 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 16 def out @out end |
#skip ⇒ Object (readonly)
Returns the value of attribute skip.
16 17 18 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 16 def skip @skip end |
Instance Method Details
#fallback_result ⇒ Object
37 38 39 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 37 def fallback_result success end |
#result ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/convenient_service/examples/standard/gemfile/services/print_shell_command.rb', line 24 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 |