Class: Scruby::ControlName

Inherits:
Object show all
Defined in:
lib/scruby/control_name.rb

Overview

:nodoc:

Constant Summary

RATES =
{ 'n_' => :noncontrol, 'i_' => :scalar, 'k_' => :control, 't_' => :trigger }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, rate, index) ⇒ ControlName

Returns a new instance of ControlName



6
7
8
# File 'lib/scruby/control_name.rb', line 6

def initialize name, value, rate, index
  @name, @value, @rate, @index = name.to_s, value.to_f, set_rate( name, rate ), index
end

Instance Attribute Details

#indexObject

Returns the value of attribute index



3
4
5
# File 'lib/scruby/control_name.rb', line 3

def index
  @index
end

#nameObject

Returns the value of attribute name



3
4
5
# File 'lib/scruby/control_name.rb', line 3

def name
  @name
end

#rateObject

Returns the value of attribute rate



3
4
5
# File 'lib/scruby/control_name.rb', line 3

def rate
  @rate
end

#valueObject

Returns the value of attribute value



3
4
5
# File 'lib/scruby/control_name.rb', line 3

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
25
26
27
# File 'lib/scruby/control_name.rb', line 22

def == other
  @name  == other.name  and
  @value == other.value and
  @rate  == other.rate  and
  @index == other.index
end

#non_control?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/scruby/control_name.rb', line 18

def non_control?
  @rate == :noncontrol
end

#rate_from_name(name) ⇒ Object



14
15
16
# File 'lib/scruby/control_name.rb', line 14

def rate_from_name name
  RATES[ name.to_s[0..1] ] || :control
end

#set_rate(name, rate) ⇒ Object



10
11
12
# File 'lib/scruby/control_name.rb', line 10

def set_rate name, rate
  RATES.has_value?( rate ) ? rate : rate_from_name( name )
end