Class: ThomasUtils::ConstantVar
- Inherits:
-
Struct
- Object
- Struct
- ThomasUtils::ConstantVar
- Defined in:
- lib/thomas_utils/constant_var.rb
Instance Attribute Summary collapse
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#time ⇒ Object
Returns the value of attribute time.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #add_observer(observer = nil, func = :update, &block) ⇒ Object
- #count_observers ⇒ Object
- #delete_observer(_) ⇒ Object
- #delete_observers ⇒ Object
- #value! ⇒ Object
- #with_observer(observer = nil, func = :update, &block) ⇒ Object
Instance Attribute Details
#reason ⇒ Object
Returns the value of attribute reason
2 3 4 |
# File 'lib/thomas_utils/constant_var.rb', line 2 def reason @reason end |
#time ⇒ Object
Returns the value of attribute time
2 3 4 |
# File 'lib/thomas_utils/constant_var.rb', line 2 def time @time end |
#value ⇒ Object
Returns the value of attribute value
2 3 4 |
# File 'lib/thomas_utils/constant_var.rb', line 2 def value @value end |
Class Method Details
.error(error) ⇒ Object
12 13 14 |
# File 'lib/thomas_utils/constant_var.rb', line 12 def self.error(error) new(Time.now, nil, error) end |
.none ⇒ Object
8 9 10 |
# File 'lib/thomas_utils/constant_var.rb', line 8 def self.none new(Time.now, nil, nil) end |
.value(value) ⇒ Object
4 5 6 |
# File 'lib/thomas_utils/constant_var.rb', line 4 def self.value(value) new(Time.now, value, nil) end |
Instance Method Details
#add_observer(observer = nil, func = :update, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/thomas_utils/constant_var.rb', line 21 def add_observer(observer = nil, func = :update, &block) if block observer = block func = :call end observer.public_send(func, time, value, reason) end |
#count_observers ⇒ Object
42 43 44 |
# File 'lib/thomas_utils/constant_var.rb', line 42 def count_observers raise NotImplementedError end |
#delete_observer(_) ⇒ Object
34 35 36 |
# File 'lib/thomas_utils/constant_var.rb', line 34 def delete_observer(_) raise NotImplementedError end |
#delete_observers ⇒ Object
38 39 40 |
# File 'lib/thomas_utils/constant_var.rb', line 38 def delete_observers raise NotImplementedError end |
#value! ⇒ Object
16 17 18 19 |
# File 'lib/thomas_utils/constant_var.rb', line 16 def value! raise reason if reason value end |
#with_observer(observer = nil, func = :update, &block) ⇒ Object
29 30 31 32 |
# File 'lib/thomas_utils/constant_var.rb', line 29 def with_observer(observer = nil, func = :update, &block) add_observer(observer, func, &block) self end |