Class: SimpleMetrics::Instrument

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_metrics/instrument.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Instrument



6
7
8
9
10
11
12
13
# File 'lib/simple_metrics/instrument.rb', line 6

def initialize(attributes)
  @id          = attributes[:id]
  @name        = attributes[:name]
  @renderer    = attributes[:renderer] || 'line'
  @created_at  = attributes[:created_at]
  @updated_at  = attributes[:updated_at]
  @metrics     = attributes[:metrics] || []
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/simple_metrics/instrument.rb', line 4

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/simple_metrics/instrument.rb', line 4

def id
  @id
end

#metricsObject

Returns the value of attribute metrics.



4
5
6
# File 'lib/simple_metrics/instrument.rb', line 4

def metrics
  @metrics
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/simple_metrics/instrument.rb', line 4

def name
  @name
end

#rendererObject

Returns the value of attribute renderer.



4
5
6
# File 'lib/simple_metrics/instrument.rb', line 4

def renderer
  @renderer
end

#updated_atObject

Returns the value of attribute updated_at.



4
5
6
# File 'lib/simple_metrics/instrument.rb', line 4

def updated_at
  @updated_at
end

Instance Method Details

#attributesObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/simple_metrics/instrument.rb', line 15

def attributes
  { 
    :id          => @id.to_s, # convert bson id to str
    :name        => @name,
    :renderer    => @renderer,
    :metrics     => @metrics,
    :created_at  => @created_at,
    :updated_at  => @updated_at
  }
end

#to_sObject



26
27
28
# File 'lib/simple_metrics/instrument.rb', line 26

def to_s
  attributes.to_s
end