Class: GraphiteMetric::Plaintext
- Inherits:
-
Struct
- Object
- Struct
- GraphiteMetric::Plaintext
- Defined in:
- lib/graphite-metric/plaintext.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Plaintext
constructor
A new instance of Plaintext.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Plaintext
Returns a new instance of Plaintext.
3 4 5 6 |
# File 'lib/graphite-metric/plaintext.rb', line 3 def initialize(*args) super self[:timestamp] ||= Time.now.utc.to_i end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key
2 3 4 |
# File 'lib/graphite-metric/plaintext.rb', line 2 def key @key end |
#timestamp ⇒ Object
Returns the value of attribute timestamp
2 3 4 |
# File 'lib/graphite-metric/plaintext.rb', line 2 def @timestamp end |
#value ⇒ Object
Returns the value of attribute value
2 3 4 |
# File 'lib/graphite-metric/plaintext.rb', line 2 def value @value end |
Class Method Details
.from_array(array) ⇒ Object
18 19 20 21 22 |
# File 'lib/graphite-metric/plaintext.rb', line 18 def self.from_array(array) array.inject([]) do |result, hash| result << from_hash(hash) end end |
.from_hash(hash) ⇒ Object
12 13 14 15 16 |
# File 'lib/graphite-metric/plaintext.rb', line 12 def self.from_hash(hash) metric = new members.each { |member| metric[member] = hash[member] if hash.has_key?(member) } metric end |
Instance Method Details
#to_s ⇒ Object
8 9 10 |
# File 'lib/graphite-metric/plaintext.rb', line 8 def to_s [key, value, ].join(" ") end |