Class: Proliphix::OID
- Inherits:
-
Object
- Object
- Proliphix::OID
- Defined in:
- lib/pdp/oid.rb
Overview
This is the basic encapsulation class for OIDs used by the Proliphix thermostat.
Instance Method Summary collapse
-
#[](value) ⇒ Object
Make the OIDs act as their own translator for the values that come out of the webservices interface.
-
#initialize(name, oid, readonly, valuemap = nil, scale = true) ⇒ OID
constructor
A new instance of OID.
-
#name ⇒ Object
return the name which you’ve provided.
-
#oid ⇒ Object
return the oid of the item that is used in the proliphix web service calls.
-
#ro? ⇒ Boolean
is the data from the oid read only.
Constructor Details
#initialize(name, oid, readonly, valuemap = nil, scale = true) ⇒ OID
Returns a new instance of OID.
5 6 7 8 9 10 11 |
# File 'lib/pdp/oid.rb', line 5 def initialize(name, oid, readonly, valuemap = nil, scale = true) @name = name @oid = oid @valuemap = valuemap @readonly = readonly @scale = scale end |
Instance Method Details
#[](value) ⇒ Object
Make the OIDs act as their own translator for the values that come out of the webservices interface. This is done via the array opperator because it’s doable.
We more or less get the raw value or the value divided by 10, as degrees come back as a 10x integer.
36 37 38 39 40 41 42 43 44 |
# File 'lib/pdp/oid.rb', line 36 def [](value) if @valuemap return @valuemap[value.to_i] elsif @scale return value.to_i / 10.0 else return value.to_i end end |
#name ⇒ Object
return the name which you’ve provided. This should be a basic string.
21 22 23 |
# File 'lib/pdp/oid.rb', line 21 def name return @name end |
#oid ⇒ Object
return the oid of the item that is used in the proliphix web service calls. This is typically of the format ‘4.1.12’ or ‘4.5.2’
16 17 18 |
# File 'lib/pdp/oid.rb', line 16 def oid return @oid end |
#ro? ⇒ Boolean
is the data from the oid read only.
26 27 28 |
# File 'lib/pdp/oid.rb', line 26 def ro? return @readonly end |