Class: RETerm::Components::VSlider

Inherits:
RETerm::Component show all
Includes:
RETerm::ComponentInput
Defined in:
lib/reterm/components/vslider.rb

Overview

Vertical Slider Component

Constant Summary

Constants included from RETerm::ComponentInput

RETerm::ComponentInput::DEC_CONTROLS, RETerm::ComponentInput::INC_CONTROLS, RETerm::ComponentInput::QUIT_CONTROLS

Instance Attribute Summary collapse

Attributes inherited from RETerm::Component

#window

Instance Method Summary collapse

Methods included from RETerm::ComponentInput

#handle_input

Methods inherited from RETerm::Component

#colored?, #colors=, #finalize!

Constructor Details

#initialize(args = {}) ⇒ VSlider

Initialize the slider component

Parameters:

  • args (Hash) (defaults to: {})

    slider params



12
13
14
15
16
17
18
# File 'lib/reterm/components/vslider.rb', line 12

def initialize(args={})
  @initial_value = 0
  @increment     = 0.01
  @range         = [0, 1]
  @labels        = true
  @value = initial_value
end

Instance Attribute Details

#incrementObject

Returns the value of attribute increment.



7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def increment
  @increment
end

#initial_valueObject

Returns the value of attribute initial_value.



7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def initial_value
  @initial_value
end

#labelsObject

Returns the value of attribute labels.



7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def labels
  @labels
end

#rangeObject

Returns the value of attribute range.



7
8
9
# File 'lib/reterm/components/vslider.rb', line 7

def range
  @range
end

Instance Method Details

#activatable?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/reterm/components/vslider.rb', line 24

def activatable?
  true
end

#activate!Object



28
29
30
31
32
# File 'lib/reterm/components/vslider.rb', line 28

def activate!
  refresh_win
  handle_input
  (range[1] - range[0]) * @value
end

#draw!Object



20
21
22
# File 'lib/reterm/components/vslider.rb', line 20

def draw!
  refresh_win
end