Class: Measure

Inherits:
Object show all
Defined in:
lib/mobiusloop/measure.rb

Overview

Records a measurement of a specific value at a specific time Once created, measures are immutable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, time = Time.now) ⇒ Measure

constructor that records a value and a time that defaults to Time.now unless overridden) constructor that records value at a defined time (instance of Time). Only number values allowed.



12
13
14
15
16
17
# File 'lib/mobiusloop/measure.rb', line 12

def initialize(value, time = Time.now)
  raise "Error! Only numbers are allowed for Measure values" unless value.is_a? Numeric
  raise "Error! Only Time is allowed for Measure time" unless time.is_a? Time
  @value = value
  @time = time
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



7
8
9
# File 'lib/mobiusloop/measure.rb', line 7

def time
  @time
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/mobiusloop/measure.rb', line 6

def value
  @value
end