Class: Eeml::DataStream
Overview
One of the component classes of Environment. Represents an individual datastream, and provides access to it’s value and other attributes. Environments can have zero or more datastreams.
Instance Attribute Summary collapse
-
#has_tag_element ⇒ Object
Returns the value of attribute has_tag_element.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#unit_symbol ⇒ Object
Returns the value of attribute unit_symbol.
-
#unit_type ⇒ Object
Returns the value of attribute unit_type.
-
#unit_value ⇒ Object
Returns the value of attribute unit_value.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #add_value(value) ⇒ Object
-
#initialize(options = {}) ⇒ DataStream
constructor
A new instance of DataStream.
- #max_value ⇒ Object
- #min_value ⇒ Object
- #recorded_at ⇒ Object
- #remove_last_value ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DataStream
Returns a new instance of DataStream.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/eeml/environment.rb', line 27 def initialize( = {}) @identifier = [:identifier] @tags = [] @has_tag_element = false @unit_symbol = [:unit_symbol] @unit_type = [:unit_type] @unit_value = [:unit_value] @values = [] @values << Value.new(:value => [:value], :max_value => [:max_value], :min_value => [:min_value], :recorded_at => [:recorded_at]) end |
Instance Attribute Details
#has_tag_element ⇒ Object
Returns the value of attribute has_tag_element.
24 25 26 |
# File 'lib/eeml/environment.rb', line 24 def has_tag_element @has_tag_element end |
#identifier ⇒ Object
Returns the value of attribute identifier.
24 25 26 |
# File 'lib/eeml/environment.rb', line 24 def identifier @identifier end |
#tags ⇒ Object
Returns the value of attribute tags.
24 25 26 |
# File 'lib/eeml/environment.rb', line 24 def @tags end |
#unit_symbol ⇒ Object
Returns the value of attribute unit_symbol.
24 25 26 |
# File 'lib/eeml/environment.rb', line 24 def unit_symbol @unit_symbol end |
#unit_type ⇒ Object
Returns the value of attribute unit_type.
24 25 26 |
# File 'lib/eeml/environment.rb', line 24 def unit_type @unit_type end |
#unit_value ⇒ Object
Returns the value of attribute unit_value.
24 25 26 |
# File 'lib/eeml/environment.rb', line 24 def unit_value @unit_value end |
#values ⇒ Object
Returns the value of attribute values.
25 26 27 |
# File 'lib/eeml/environment.rb', line 25 def values @values end |
Instance Method Details
#add_value(value) ⇒ Object
41 42 43 |
# File 'lib/eeml/environment.rb', line 41 def add_value(value) @values << value end |
#max_value ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/eeml/environment.rb', line 57 def max_value unless @values.last.nil? return @values.last.max_value else return nil end end |
#min_value ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/eeml/environment.rb', line 49 def min_value unless @values.last.nil? return @values.last.min_value else return nil end end |
#recorded_at ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/eeml/environment.rb', line 73 def recorded_at unless @values.last.nil? return @values.last.recorded_at else return nil end end |
#remove_last_value ⇒ Object
45 46 47 |
# File 'lib/eeml/environment.rb', line 45 def remove_last_value @values.pop end |
#to_s ⇒ Object
81 82 83 |
# File 'lib/eeml/environment.rb', line 81 def to_s "identifier: '#{@identifier}', value: '#{@value}', min_value: '#{@min_value}', max_value: '#{@max_value}', tags: '#{@tags.join(", ")}'" end |
#value ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/eeml/environment.rb', line 65 def value unless @values.last.nil? return @values.last.value else return nil end end |