Class: DialogTui::Option
- Inherits:
-
Object
- Object
- DialogTui::Option
- Defined in:
- lib/dialog_tui.rb
Overview
NOTE: not sure about perfomance implications of that chain of &block passing instead of just using variable w/o ‘&` but & looks very explicit and is not as annoying as additional parameter
Instance Method Summary collapse
- #call ⇒ Object
- #chosen? ⇒ Boolean
-
#initialize(dialog, text, &reaction) ⇒ Option
constructor
A new instance of Option.
-
#print(printer = nil) ⇒ Object
just to be here for future.
Constructor Details
#initialize(dialog, text, &reaction) ⇒ Option
Returns a new instance of Option.
126 127 128 129 130 |
# File 'lib/dialog_tui.rb', line 126 def initialize dialog, text, &reaction @dialog = dialog @text = text.to_s @reaction = reaction end |
Instance Method Details
#call ⇒ Object
132 133 134 |
# File 'lib/dialog_tui.rb', line 132 def call @reaction.call end |
#chosen? ⇒ Boolean
145 146 147 |
# File 'lib/dialog_tui.rb', line 145 def chosen? @dialog.chosen? self end |
#print(printer = nil) ⇒ Object
just to be here for future
136 137 138 139 140 141 142 143 |
# File 'lib/dialog_tui.rb', line 136 def print printer=nil # just to be here for future # refactoring if chosen? puts '=> ' + @text else puts ' ' + @text end end |