Sha256: ea63cd6035b2d6aaa2e0ff447faa12d15a1ee1905d728dbb65589589c37c88e9

Contents?: true

Size: 789 Bytes

Versions: 3

Compression:

Stored size: 789 Bytes

Contents

module Reality
  class Observation
    attr_reader :entity_uri, :variable, :value, :time, :source

    def initialize(entity_uri, variable, value, source: nil, time: nil)
      @entity_uri = entity_uri
      @variable = variable
      @value = value
      @time = time
      @source = source
    end

    def inspect
      if timed?
        '#<%s %s=%s (%s)>' % [self.class.name, variable, value, time.strftime('%Y-%m-%d at %H:%M:%S')]
      else
        '#<%s[%s] %s=%s>' % [self.class.name, entity_uri, variable, value]
      end
    end

    def to_s
      '%s=%p' % [variable, value]
    end

    def ==(other)
      other.is_a?(Observation) && variable == other.variable && value == other.value &&
        time == other.time
    end

    def timed?
      !time.nil?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reality-0.1.0.alpha3 lib/reality/observation.rb
reality-0.1.0.alpha2 lib/reality/observation.rb
reality-0.1.0.alpha lib/reality/observation.rb