Sha256: 01385f7790b5ac9cfcff3a31160df05d614c4e39c06f8b53ed53a688af4fc659

Contents?: true

Size: 601 Bytes

Versions: 3

Compression:

Stored size: 601 Bytes

Contents

module Spectator
  # This immutable class represents a measurement sampled from a meter
  class Measure
    attr_reader :id, :value

    # A meter id and a value
    def initialize(id, value)
      @id = id
      @value = value.to_f
    end

    # A string representation of this measurement, for debugging purposes
    def to_s
      "Measure{id=#{@id}, value=#{@value}}"
    end

    # Compare this measurement against another one,
    # taking into account nan values
    def ==(other)
      @id == other.id && (@value == other.value ||
          @value.nan? && other.value.nan?)
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
netflix-spectator-rb-0.1.3 lib/spectator/measure.rb
netflix-spectator-rb-0.1.1 lib/spectator/measure.rb
spectator-rb-0.1.0 lib/spectator/measure.rb