Class: LEDENET::FunctionSpeed

Inherits:
Object
  • Object
show all
Defined in:
lib/ledenet/function_speed.rb

Constant Summary collapse

INTERFACE_SPEED_RANGE =

Speed range exposed through API

(1..100)
PACKET_SPEED_RANGE =

Speed value is in [0x01, 0x1F], with 0x00 being the fastest.

(0x01..0x1F)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ FunctionSpeed

Returns a new instance of FunctionSpeed.



11
12
13
# File 'lib/ledenet/function_speed.rb', line 11

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/ledenet/function_speed.rb', line 9

def value
  @value
end

Class Method Details

.from_packet_value(value) ⇒ Object



23
24
25
26
# File 'lib/ledenet/function_speed.rb', line 23

def self.from_packet_value(value)
  v = FunctionSpeed.convert_range(value, PACKET_SPEED_RANGE, INTERFACE_SPEED_RANGE)
  FunctionSpeed.new(v)
end

.from_value(value) ⇒ Object



19
20
21
# File 'lib/ledenet/function_speed.rb', line 19

def self.from_value(value)
  FunctionSpeed.new(value)
end

Instance Method Details

#packet_valueObject



15
16
17
# File 'lib/ledenet/function_speed.rb', line 15

def packet_value
  FunctionSpeed.convert_range(value, INTERFACE_SPEED_RANGE, PACKET_SPEED_RANGE)
end