Class: RZWaveWay::Property
- Inherits:
-
Object
- Object
- RZWaveWay::Property
- Defined in:
- lib/rzwaveway/property.rb
Instance Attribute Summary collapse
-
#update_time ⇒ Object
readonly
Returns the value of attribute update_time.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(options) ⇒ Property
constructor
A new instance of Property.
- #read_only? ⇒ Boolean
- #save ⇒ Object
- #to_hash ⇒ Object
- #update(value, update_time) ⇒ Object
Constructor Details
#initialize(options) ⇒ Property
Returns a new instance of Property.
6 7 8 9 10 |
# File 'lib/rzwaveway/property.rb', line 6 def initialize() @previous_value = @value = [:value] @previous_update_time = @update_time = [:update_time] @read_only = [:read_only] end |
Instance Attribute Details
#update_time ⇒ Object (readonly)
Returns the value of attribute update_time.
4 5 6 |
# File 'lib/rzwaveway/property.rb', line 4 def update_time @update_time end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/rzwaveway/property.rb', line 3 def value @value end |
Instance Method Details
#changed? ⇒ Boolean
12 13 14 |
# File 'lib/rzwaveway/property.rb', line 12 def changed? @previous_value != @value end |
#read_only? ⇒ Boolean
16 17 18 |
# File 'lib/rzwaveway/property.rb', line 16 def read_only? @read_only == true end |
#save ⇒ Object
20 21 22 23 |
# File 'lib/rzwaveway/property.rb', line 20 def save @previous_value = @value @previous_update_time = @update_time end |
#to_hash ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rzwaveway/property.rb', line 25 def to_hash { read_only: read_only?, value: @value, update_time: @update_time } end |
#update(value, update_time) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rzwaveway/property.rb', line 33 def update(value, update_time) if @update_time <= update_time @update_time = update_time if @value != value @value = value true else false end else false end end |