Class: Microphite::Metric

Inherits:
Object
  • Object
show all
Defined in:
lib/microphite/metric.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, time = nil) ⇒ Metric

Returns a new instance of Metric.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/microphite/metric.rb', line 5

def initialize(key, value, time=nil)
  raise(ArgumentError, 'key cannot be nil') if key.nil?
  raise(ArgumentError, 'value cannot be nil') if value.nil?

  @key = key.to_s
  @value = to_f! value
  if time.nil?
    @time = Time.now.to_f
  else
    @time = to_f! time
  end

  raise(ArgumentError, "invalid key: #{key}") if @key.empty?
  raise(ArgumentError, "invaild value: #{value} ") if @value.nil?
  raise(ArgumentError, "invalue time: #{time}") if @time.nil?
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/microphite/metric.rb', line 3

def key
  @key
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/microphite/metric.rb', line 3

def time
  @time
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/microphite/metric.rb', line 3

def value
  @value
end