Class: Shades::Metadata
- Inherits:
-
Object
- Object
- Shades::Metadata
- Defined in:
- lib/shades/model.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
Returns the value of attribute dimensions.
-
#measures ⇒ Object
Returns the value of attribute measures.
Instance Method Summary collapse
-
#initialize(dimensions, measures) ⇒ Metadata
constructor
A new instance of Metadata.
-
#parse_event(line, sep) ⇒ Object
parse an event line that adheres to this metadat.
Constructor Details
#initialize(dimensions, measures) ⇒ Metadata
Returns a new instance of Metadata.
5 6 7 8 |
# File 'lib/shades/model.rb', line 5 def initialize(dimensions, measures) @dimensions = dimensions @measures = measures end |
Instance Attribute Details
#dimensions ⇒ Object
Returns the value of attribute dimensions.
3 4 5 |
# File 'lib/shades/model.rb', line 3 def dimensions @dimensions end |
#measures ⇒ Object
Returns the value of attribute measures.
4 5 6 |
# File 'lib/shades/model.rb', line 4 def measures @measures end |
Instance Method Details
#parse_event(line, sep) ⇒ Object
parse an event line that adheres to this metadat
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/shades/model.rb', line 11 def parse_event(line, sep) values = line.split(sep) begin d = {} @dimensions.zip(values.take(@dimensions.length)).each do |k, v| d[k] = v.strip end m = {} @measures.zip(values.drop(@dimensions.length)).each do |k, v| m[k] = Float(v.strip) end return Event.new(self, d, m) rescue => err puts err. puts "line: #{line}" end nil end |