Class: SimpleMetrics::Metric
- Inherits:
-
Object
- Object
- SimpleMetrics::Metric
- Defined in:
- lib/simple_metrics/metric.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#total ⇒ Object
Returns the value of attribute total.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(attributes) ⇒ Metric
constructor
A new instance of Metric.
- #to_s ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Metric
Returns a new instance of Metric.
7 8 9 10 11 12 13 |
# File 'lib/simple_metrics/metric.rb', line 7 def initialize(attributes) @id = attributes[:id] @name = attributes[:name] @total = attributes[:total] @created_at = attributes[:created_at] @updated_at = attributes[:updated_at] end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/simple_metrics/metric.rb', line 4 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/simple_metrics/metric.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/simple_metrics/metric.rb', line 4 def name @name end |
#total ⇒ Object
Returns the value of attribute total.
5 6 7 |
# File 'lib/simple_metrics/metric.rb', line 5 def total @total end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/simple_metrics/metric.rb', line 4 def updated_at @updated_at end |
Instance Method Details
#attributes ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/simple_metrics/metric.rb', line 15 def attributes { :id => @id.to_s, # convert bson id to str :name => @name, :total => @total, :created_at => @created_at, :updated_at => @updated_at } end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/simple_metrics/metric.rb', line 25 def to_s attributes.to_s end |