Class: Shades::Event
- Inherits:
-
Object
- Object
- Shades::Event
- Defined in:
- lib/shades/model.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
- #dimension(d) ⇒ Object
- #dimensions ⇒ Object
-
#initialize(metadata, dimensions, measures) ⇒ Event
constructor
A new instance of Event.
- #key ⇒ Object
- #line ⇒ Object
- #measure(m) ⇒ Object
- #measures ⇒ Object
Constructor Details
#initialize(metadata, dimensions, measures) ⇒ Event
Returns a new instance of Event.
35 36 37 38 39 40 |
# File 'lib/shades/model.rb', line 35 def initialize(, dimensions, measures) @metadata = @dvalues = dimensions @mvalues = measures @key = @dvalues.keys.map{ |k| k + "=" + @dvalues.fetch(k) }.join(";") end |
Instance Attribute Details
#metadata ⇒ Object
Returns the value of attribute metadata.
33 34 35 |
# File 'lib/shades/model.rb', line 33 def @metadata end |
Instance Method Details
#dimension(d) ⇒ Object
46 47 48 |
# File 'lib/shades/model.rb', line 46 def dimension(d) @dvalues[d] end |
#dimensions ⇒ Object
54 55 56 |
# File 'lib/shades/model.rb', line 54 def dimensions @metadata.dimensions end |
#key ⇒ Object
42 43 44 |
# File 'lib/shades/model.rb', line 42 def key @key end |
#line ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/shades/model.rb', line 62 def line f = [] f << @metadata.dimensions.map { |k| '%s' % dimension(k) } f << @metadata.measures.map { |k| '%.5f' % measure(k) } puts f.inspect f.join("\t") end |
#measure(m) ⇒ Object
50 51 52 |
# File 'lib/shades/model.rb', line 50 def measure(m) @mvalues[m] end |
#measures ⇒ Object
58 59 60 |
# File 'lib/shades/model.rb', line 58 def measures @metadata.measures end |