Class: RETerm::Components::Dial

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

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 = {}) ⇒ Dial

Enapsulating window should be at least 4x4 for decent effect, at least 7x7 provides best resolution

Examples:

activating a dial

win  = Window.new
dial = Dial.new
win.component = dial

val = dial.activate!

Parameters:

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

    dial params



22
23
24
25
26
27
28
# File 'lib/reterm/components/dial.rb', line 22

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.



6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def increment
  @increment
end

#initial_valueObject

Returns the value of attribute initial_value.



6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def initial_value
  @initial_value
end

#labelsObject

Returns the value of attribute labels.



6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def labels
  @labels
end

#rangeObject

Returns the value of attribute range.



6
7
8
# File 'lib/reterm/components/dial.rb', line 6

def range
  @range
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/reterm/components/dial.rb', line 8

def value
  @value
end

Instance Method Details

#activatable?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/reterm/components/dial.rb', line 34

def activatable?
  true
end

#activate!Object



38
39
40
41
42
# File 'lib/reterm/components/dial.rb', line 38

def activate!
  refresh_win
  handle_input
  @value
end

#draw!Object



30
31
32
# File 'lib/reterm/components/dial.rb', line 30

def draw!
  refresh_win
end