Class: Expressir::Commands::Base
- Inherits:
-
Object
- Object
- Expressir::Commands::Base
- Defined in:
- lib/expressir/commands/base.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #exit_with_error(message, exit_code = 1) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
-
#say(message) ⇒ Object
Common utilities that all commands might need.
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/expressir/commands/base.rb', line 6 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/expressir/commands/base.rb', line 4 def @options end |
Instance Method Details
#exit_with_error(message, exit_code = 1) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/expressir/commands/base.rb', line 20 def exit_with_error(, exit_code = 1) say # In test mode, raise an exception instead of exiting # This makes it easier to test error cases if defined?(@test_mode) && @test_mode raise # Just raise the message as an exception else exit exit_code end end |
#say(message) ⇒ Object
Common utilities that all commands might need
11 12 13 14 15 16 17 18 |
# File 'lib/expressir/commands/base.rb', line 11 def say() # Use instance variable for testability - if output is set, use it if defined?(@output) && @output @output.puts() else puts() end end |