Class: Jylis::DataType::TREG::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/jylis-rb/data_types/treg.rb

Overview

The result of a TREG query.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, timestamp) ⇒ Result

Returns a new instance of Result.



21
22
23
24
# File 'lib/jylis-rb/data_types/treg.rb', line 21

def initialize(value, timestamp)
  @value     = value
  @timestamp = timestamp
end

Instance Attribute Details

#timestampObject (readonly)

Returns the value of attribute timestamp.



10
11
12
# File 'lib/jylis-rb/data_types/treg.rb', line 10

def timestamp
  @timestamp
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/jylis-rb/data_types/treg.rb', line 9

def value
  @value
end

Class Method Details

.parse(query_result) ⇒ Jylis::DataType::TREG::Result

Construct a Result from a raw query result.

Parameters:

  • query_result (Array)

Returns:



17
18
19
# File 'lib/jylis-rb/data_types/treg.rb', line 17

def self.parse(query_result)
  new(query_result[0], query_result[1])
end

Instance Method Details

#==(other) ⇒ Object

:nodoc:



27
28
29
30
# File 'lib/jylis-rb/data_types/treg.rb', line 27

def ==(other)
  other.value == self.value &&
  other.timestamp == self.timestamp
end

#timeTime

Returns the timestamp as a Time object.

Returns:

  • (Time)

    the timestamp as a Time object



38
39
40
# File 'lib/jylis-rb/data_types/treg.rb', line 38

def time
  Time.at(timestamp)
end

#timestamp_iso8601String

Returns the timestamp as an ISO8601 formatted string.

Returns:

  • (String)

    the timestamp as an ISO8601 formatted string



43
44
45
# File 'lib/jylis-rb/data_types/treg.rb', line 43

def timestamp_iso8601
  time.utc.iso8601
end

#to_aObject

Reconstruct the raw result returned by the database.



33
34
35
# File 'lib/jylis-rb/data_types/treg.rb', line 33

def to_a
  [value, timestamp]
end