Class: Audiothority::Change
- Inherits:
-
Object
- Object
- Audiothority::Change
- Defined in:
- lib/audiothority/change.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(field, choices, tags) ⇒ Change
constructor
A new instance of Change.
- #perform ⇒ Object
- #present(display) ⇒ Object
Constructor Details
#initialize(field, choices, tags) ⇒ Change
Returns a new instance of Change.
5 6 7 8 9 |
# File 'lib/audiothority/change.rb', line 5 def initialize(field, choices, ) @field = field @choices = choices = end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/audiothority/change.rb', line 11 def perform if performable? .each do |tag| tag.send(tag_setter, value) end end end |
#present(display) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/audiothority/change.rb', line 19 def present(display) if performable? ignored = @choices.reject { |k, _| k == value } ignored = ignored.map do |v, c| %("#{display.set_color(v, :red)}" (#{c})) end chosen = %("#{display.set_color(value, :green)}" (#{@choices[value]})) table = ignored.map do |i| [display.set_color(@field, :yellow), i, '~>', chosen] end display.print_table(table, indent: 2) end end |