Class: Eeml::DataStream

Inherits:
Object show all
Defined in:
lib/eeml/environment.rb

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

Instance Method Summary collapse

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(options = {})
  @identifier = options[:identifier]
  @tags = []
  @has_tag_element = false
  @unit_symbol = options[:unit_symbol]
  @unit_type = options[:unit_type]
  @unit_value = options[:unit_value]
  @values = []
  @values << Value.new(:value => options[:value], 
                       :max_value => options[:max_value], 
                       :min_value => options[:min_value], 
                       :recorded_at => options[:recorded_at])
end

Instance Attribute Details

#has_tag_elementObject

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

#identifierObject

Returns the value of attribute identifier.



24
25
26
# File 'lib/eeml/environment.rb', line 24

def identifier
  @identifier
end

#tagsObject

Returns the value of attribute tags.



24
25
26
# File 'lib/eeml/environment.rb', line 24

def tags
  @tags
end

#unit_symbolObject

Returns the value of attribute unit_symbol.



24
25
26
# File 'lib/eeml/environment.rb', line 24

def unit_symbol
  @unit_symbol
end

#unit_typeObject

Returns the value of attribute unit_type.



24
25
26
# File 'lib/eeml/environment.rb', line 24

def unit_type
  @unit_type
end

#unit_valueObject

Returns the value of attribute unit_value.



24
25
26
# File 'lib/eeml/environment.rb', line 24

def unit_value
  @unit_value
end

#valuesObject

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_valueObject



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_valueObject



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_atObject



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_valueObject



45
46
47
# File 'lib/eeml/environment.rb', line 45

def remove_last_value
  @values.pop
end

#to_sObject



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

#valueObject



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