Class: Jylis::DataType::TLOG::Row

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

Overview

A row (data point) in a TLOG::Result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, timestamp) ⇒ Row

Returns a new instance of Row.



64
65
66
67
# File 'lib/jylis-rb/data_types/tlog.rb', line 64

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

Instance Attribute Details

#timestampObject (readonly)

Returns the value of attribute timestamp.



53
54
55
# File 'lib/jylis-rb/data_types/tlog.rb', line 53

def timestamp
  @timestamp
end

#valueObject (readonly)

Returns the value of attribute value.



52
53
54
# File 'lib/jylis-rb/data_types/tlog.rb', line 52

def value
  @value
end

Class Method Details

.parse(query_row) ⇒ Jylis::DataType::TLOG::Row

Construct a Row from a raw query row.

Parameters:

  • query_row (Array)

Returns:



60
61
62
# File 'lib/jylis-rb/data_types/tlog.rb', line 60

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

Instance Method Details

#==(other) ⇒ Object

:nodoc:



70
71
72
73
# File 'lib/jylis-rb/data_types/tlog.rb', line 70

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



81
82
83
# File 'lib/jylis-rb/data_types/tlog.rb', line 81

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



86
87
88
# File 'lib/jylis-rb/data_types/tlog.rb', line 86

def timestamp_iso8601
  time.utc.iso8601
end

#to_aObject

Reconstruct the raw result returned by the database.



76
77
78
# File 'lib/jylis-rb/data_types/tlog.rb', line 76

def to_a
  [value, timestamp]
end