Class: Babushka::Cmdline::Handler
- Defined in:
- lib/babushka/cmdline/handler.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opt_definer ⇒ Object
readonly
Returns the value of attribute opt_definer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, description, opt_definer) ⇒ Handler
constructor
A new instance of Handler.
- #run(&handler) ⇒ Object
Constructor Details
#initialize(name, description, opt_definer) ⇒ Handler
Returns a new instance of Handler.
36 37 38 |
# File 'lib/babushka/cmdline/handler.rb', line 36 def initialize name, description, opt_definer @name, @description, @opt_definer = name, description, (opt_definer || L{}) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
34 35 36 |
# File 'lib/babushka/cmdline/handler.rb', line 34 def description @description end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
34 35 36 |
# File 'lib/babushka/cmdline/handler.rb', line 34 def handler @handler end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/babushka/cmdline/handler.rb', line 34 def name @name end |
#opt_definer ⇒ Object (readonly)
Returns the value of attribute opt_definer.
34 35 36 |
# File 'lib/babushka/cmdline/handler.rb', line 34 def opt_definer @opt_definer end |
Class Method Details
.abbrev ⇒ Object
26 27 28 |
# File 'lib/babushka/cmdline/handler.rb', line 26 def self.abbrev all.map(&:name).abbrev end |
.add(name, description, opt_definer) ⇒ Object
16 17 18 19 20 |
# File 'lib/babushka/cmdline/handler.rb', line 16 def self.add name, description, opt_definer Handler.new(name, description, opt_definer).tap {|handler| (@handlers ||= []).push handler } end |
.all ⇒ Object
22 23 24 |
# File 'lib/babushka/cmdline/handler.rb', line 22 def self.all @handlers.reject {|h| h.name == 'global' } end |
.for(name) ⇒ Object
30 31 32 |
# File 'lib/babushka/cmdline/handler.rb', line 30 def self.for name @handlers.detect {|h| h.name == name } end |
Instance Method Details
#run(&handler) ⇒ Object
40 41 42 |
# File 'lib/babushka/cmdline/handler.rb', line 40 def run &handler @handler = handler end |