Class: RETerm::Components::Rocker
- Inherits:
-
RETerm::Component
- Object
- RETerm::Component
- RETerm::Components::Rocker
- Includes:
- RETerm::ComponentInput, ItemHelpers
- Defined in:
- lib/reterm/components/rocker.rb
Overview
Rocker component, allowing use to select one of several items
Constant Summary
Constants included from RETerm::CommonKeys
RETerm::CommonKeys::DEC_CONTROLS, RETerm::CommonKeys::ENTER_CONTROLS, RETerm::CommonKeys::INC_CONTROLS, RETerm::CommonKeys::QUIT_CONTROLS
Constants included from LogHelpers
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#items ⇒ Object
Returns the value of attribute items.
-
#labels ⇒ Object
Returns the value of attribute labels.
Attributes included from RETerm::CommonControls
Attributes inherited from RETerm::Component
#activatable, #activate_focus, #highlight_focus, #window
Instance Method Summary collapse
- #activatable? ⇒ Boolean
- #activate!(*input) ⇒ Object
- #draw! ⇒ Object
-
#initialize(args = {}) ⇒ Rocker
constructor
Initialize the Rocker component.
- #requested_cols ⇒ Object
- #requested_rows ⇒ Object
Methods included from ItemHelpers
Methods included from RETerm::ComponentInput
#bind_key, #handle_input, #key_bound?, #on_enter, #on_key
Methods included from RETerm::CommonControls
Methods inherited from RETerm::Component
#activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch
Methods included from KeyBindings
#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?
Methods included from LogHelpers
Methods included from EventDispatcher
Constructor Details
#initialize(args = {}) ⇒ Rocker
Initialize the Rocker component
21 22 23 24 25 26 27 |
# File 'lib/reterm/components/rocker.rb', line 21 def initialize(args={}) super @items = [] @index = nil @labels = true @index = 0 end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
8 9 10 |
# File 'lib/reterm/components/rocker.rb', line 8 def index @index end |
#items ⇒ Object
Returns the value of attribute items.
8 9 10 |
# File 'lib/reterm/components/rocker.rb', line 8 def items @items end |
#labels ⇒ Object
Returns the value of attribute labels.
8 9 10 |
# File 'lib/reterm/components/rocker.rb', line 8 def labels @labels end |
Instance Method Details
#activatable? ⇒ Boolean
41 42 43 |
# File 'lib/reterm/components/rocker.rb', line 41 def activatable? true end |
#activate!(*input) ⇒ Object
45 46 47 48 49 |
# File 'lib/reterm/components/rocker.rb', line 45 def activate!(*input) refresh_win handle_input(*input) @items[@index] end |
#draw! ⇒ Object
37 38 39 |
# File 'lib/reterm/components/rocker.rb', line 37 def draw! refresh_win end |
#requested_cols ⇒ Object
33 34 35 |
# File 'lib/reterm/components/rocker.rb', line 33 def requested_cols max_item_size + 3 end |
#requested_rows ⇒ Object
29 30 31 |
# File 'lib/reterm/components/rocker.rb', line 29 def requested_rows @items.size + 3 end |