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

- (ControlName) initialize(name, value, rate, index)



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

- (Object) index

Returns the value of attribute index



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

def index
  @index
end

- (Object) name

Returns the value of attribute name



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

def name
  @name
end

- (Object) rate

Returns the value of attribute rate



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

def rate
  @rate
end

- (Object) value

Returns the value of attribute value



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

def value
  @value
end

Instance Method Details

- (Object) ==(other)



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

- (Boolean) non_control?



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

def non_control?
  @rate == :noncontrol
end

- (Object) rate_from_name(name)



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

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

- (Object) set_rate(name, rate)



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