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.
31 32 33 |
# File 'lib/babushka/cmdline/handler.rb', line 31 def initialize name, description, opt_definer @name, @description, @opt_definer = name, description, (opt_definer || proc{}) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
29 30 31 |
# File 'lib/babushka/cmdline/handler.rb', line 29 def description @description end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
29 30 31 |
# File 'lib/babushka/cmdline/handler.rb', line 29 def handler @handler end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
29 30 31 |
# File 'lib/babushka/cmdline/handler.rb', line 29 def name @name end |
#opt_definer ⇒ Object (readonly)
Returns the value of attribute opt_definer.
29 30 31 |
# File 'lib/babushka/cmdline/handler.rb', line 29 def opt_definer @opt_definer end |
Class Method Details
.abbrev ⇒ Object
21 22 23 |
# File 'lib/babushka/cmdline/handler.rb', line 21 def self.abbrev all.map(&:name).abbrev end |
.add(name, description, opt_definer) ⇒ Object
11 12 13 14 15 |
# File 'lib/babushka/cmdline/handler.rb', line 11 def self.add name, description, opt_definer Handler.new(name, description, opt_definer).tap {|handler| (@handlers ||= []).push handler } end |
.all ⇒ Object
17 18 19 |
# File 'lib/babushka/cmdline/handler.rb', line 17 def self.all @handlers.reject {|h| h.name == 'global' } end |
.for(name) ⇒ Object
25 26 27 |
# File 'lib/babushka/cmdline/handler.rb', line 25 def self.for name @handlers.detect {|h| h.name == name } end |
Instance Method Details
#run(&handler) ⇒ Object
35 36 37 |
# File 'lib/babushka/cmdline/handler.rb', line 35 def run &handler @handler = handler end |