Class: Lucie::Controller::Base
- Inherits:
-
Object
- Object
- Lucie::Controller::Base
- Includes:
- Validators::MandatoryOption, Validators::Optional
- Defined in:
- lib/lucie/controller/base.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Class Method Summary collapse
- .apply_validators ⇒ Object
- .pair_parameters ⇒ Object
- .params ⇒ Object
- .params=(params) ⇒ Object
- .validators ⇒ Object
Instance Method Summary collapse
- #exit(value) ⇒ Object
- #help ⇒ Object
-
#initialize(command_line_parser, app) ⇒ Base
constructor
A new instance of Base.
- #params ⇒ Object
Methods included from Validators::Optional
Methods included from Validators::MandatoryOption
Constructor Details
#initialize(command_line_parser, app) ⇒ Base
Returns a new instance of Base.
15 16 17 18 |
# File 'lib/lucie/controller/base.rb', line 15 def initialize(command_line_parser, app) self.class.params = command_line_parser @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
8 9 10 |
# File 'lib/lucie/controller/base.rb', line 8 def app @app end |
Class Method Details
.apply_validators ⇒ Object
48 49 50 |
# File 'lib/lucie/controller/base.rb', line 48 def self.apply_validators validators.each {|validator| validator.apply(params) } if validators end |
.pair_parameters ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lucie/controller/base.rb', line 37 def self.pair_parameters validators.each do |validator| short = validator.short_option long = validator.long_option if short != "" && long != "" params.pair(short, long) end end end |
.params ⇒ Object
28 29 30 |
# File 'lib/lucie/controller/base.rb', line 28 def self.params @params end |
.params=(params) ⇒ Object
20 21 22 |
# File 'lib/lucie/controller/base.rb', line 20 def self.params=(params) @params = params end |
.validators ⇒ Object
32 33 34 35 |
# File 'lib/lucie/controller/base.rb', line 32 def self.validators @validators ||= [] @validators end |
Instance Method Details
#exit(value) ⇒ Object
52 53 54 |
# File 'lib/lucie/controller/base.rb', line 52 def exit(value) raise ExitRequest, value end |
#help ⇒ Object
56 57 58 |
# File 'lib/lucie/controller/base.rb', line 56 def help "Help" end |
#params ⇒ Object
24 25 26 |
# File 'lib/lucie/controller/base.rb', line 24 def params self.class.params end |