Class: RChoice::Choice
- Includes:
- FromHash
- Defined in:
- lib/rchoice/choice.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action_blk ⇒ Object
Returns the value of attribute action_blk.
-
#chooser ⇒ Object
Returns the value of attribute chooser.
-
#name ⇒ Object
Returns the value of attribute name.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#parent_obj ⇒ Object
Returns the value of attribute parent_obj.
Instance Method Summary collapse
- #add_option(obj, &b) ⇒ Object
- #execute! ⇒ Object
- #make_option(obj, &b) ⇒ Object
- #options=(raw) ⇒ Object
Instance Attribute Details
#action_blk ⇒ Object
Returns the value of attribute action_blk.
4 5 6 |
# File 'lib/rchoice/choice.rb', line 4 def action_blk @action_blk end |
#chooser ⇒ Object
Returns the value of attribute chooser.
4 5 6 |
# File 'lib/rchoice/choice.rb', line 4 def chooser @chooser end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/rchoice/choice.rb', line 4 def name @name end |
#optional ⇒ Object
Returns the value of attribute optional.
4 5 6 |
# File 'lib/rchoice/choice.rb', line 4 def optional @optional end |
#parent_obj ⇒ Object
Returns the value of attribute parent_obj.
4 5 6 |
# File 'lib/rchoice/choice.rb', line 4 def parent_obj @parent_obj end |
Instance Method Details
#add_option(obj, &b) ⇒ Object
26 27 28 |
# File 'lib/rchoice/choice.rb', line 26 def add_option(obj,&b) self. << make_option(obj,&b) end |
#execute! ⇒ Object
17 18 19 20 |
# File 'lib/rchoice/choice.rb', line 17 def execute! return unless action_blk chosen_option.execute!(&action_blk) if chosen_option end |
#make_option(obj, &b) ⇒ Object
21 22 23 24 25 |
# File 'lib/rchoice/choice.rb', line 21 def make_option(obj,&b) return obj if obj.kind_of?(Option) obj = {:base_obj => obj} unless obj.kind_of?(Hash) Option.new(obj) end |
#options=(raw) ⇒ Object
29 30 31 |
# File 'lib/rchoice/choice.rb', line 29 def (raw) @options = raw.map { |r| make_option(r) } end |