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
Create a new 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
Create a new OID. It takes 5 parameters
* name - some name you want to make up
* oid - the oid that Proliphix uses in it's web service call
* readonly - is the attribute read only (prevents us from
ever trying to do a set call
* valuemap - if the return is fundamentally an enumeration,
provide a hash that we can map these to strings that make sense
* scale - degrees are sent back as ints which are degrees * 10.
If scale is set to true these are automatically divided by 10 before
returned so that you get the answer in degrees
16 17 18 19 20 21 22 |
# File 'lib/pdp/oid.rb', line 16 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.
47 48 49 50 51 52 53 54 55 |
# File 'lib/pdp/oid.rb', line 47 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.
32 33 34 |
# File 'lib/pdp/oid.rb', line 32 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’
27 28 29 |
# File 'lib/pdp/oid.rb', line 27 def oid return @oid end |
#ro? ⇒ Boolean
is the data from the oid read only.
37 38 39 |
# File 'lib/pdp/oid.rb', line 37 def ro? return @readonly end |