class Fluent::EventTime

Constants

FORMATTER
TYPE

Public Class Methods

eq?(a, b) click to toggle source
# File lib/fluent/time.rb, line 92
def self.eq?(a, b)
  if a.is_a?(Fluent::EventTime) && b.is_a?(Fluent::EventTime)
    a.sec == b.sec && a.nsec == b.nsec
  else
    a == b
  end
end
from_msgpack_ext(data) click to toggle source
# File lib/fluent/time.rb, line 84
def self.from_msgpack_ext(data)
  new(*data.unpack('NN'))
end
from_time(time) click to toggle source
# File lib/fluent/time.rb, line 88
def self.from_time(time)
  Fluent::EventTime.new(time.to_i, time.nsec)
end
new(sec, nsec = 0) click to toggle source
# File lib/fluent/time.rb, line 29
def initialize(sec, nsec = 0)
  @sec = sec
  @nsec = nsec
end
now() click to toggle source
# File lib/fluent/time.rb, line 100
def self.now
  from_time(Time.now)
end
parse(*args) click to toggle source
# File lib/fluent/time.rb, line 104
def self.parse(*args)
  from_time(Time.parse(*args))
end

Public Instance Methods

==(other) click to toggle source
# File lib/fluent/time.rb, line 34
def ==(other)
  if other.is_a?(Fluent::EventTime)
    @sec == other.sec
  else
    @sec == other
  end
end
coerce(other) click to toggle source

for > and others

# File lib/fluent/time.rb, line 64
def coerce(other)
  [other, @sec]
end
inspect() click to toggle source
# File lib/fluent/time.rb, line 113
def inspect
  FORMATTER.exec(Time.at(self))
end
method_missing(name, *args, &block) click to toggle source

TODO: For performance, implement +, -, and so on

# File lib/fluent/time.rb, line 109
def method_missing(name, *args, &block)
  @sec.send(name, *args, &block)
end
nsec() click to toggle source
# File lib/fluent/time.rb, line 46
def nsec
  @nsec
end
sec() click to toggle source
# File lib/fluent/time.rb, line 42
def sec
  @sec
end
to_f() click to toggle source
# File lib/fluent/time.rb, line 54
def to_f
  @sec + @nsec / 1_000_000_000.0
end
to_int() click to toggle source
# File lib/fluent/time.rb, line 50
def to_int
  @sec
end
to_json(*args) click to toggle source
# File lib/fluent/time.rb, line 72
def to_json(*args)
  @sec.to_s
end
to_msgpack(io = nil) click to toggle source
# File lib/fluent/time.rb, line 76
def to_msgpack(io = nil)
  @sec.to_msgpack(io)
end
to_msgpack_ext() click to toggle source
# File lib/fluent/time.rb, line 80
def to_msgpack_ext
  [@sec, @nsec].pack('NN')
end
to_r() click to toggle source

for Time.at

# File lib/fluent/time.rb, line 59
def to_r
  Rational(@sec * 1_000_000_000 + @nsec, 1_000_000_000)
end
to_s() click to toggle source
# File lib/fluent/time.rb, line 68
def to_s
  @sec.to_s
end