Class: DialogTui::Option

Inherits:
Object
  • Object
show all
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

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

#callObject



132
133
134
# File 'lib/dialog_tui.rb', line 132

def call
  @reaction.call
end

#chosen?Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/dialog_tui.rb', line 145

def chosen?
  @dialog.chosen? self
end

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