Parent

Class/Module Index [+]

Quicksearch

Fluent::TimeFormatter

Public Class Methods

new(format, localtime) click to toggle source
# File lib/fluent/mixin.rb, line 20
def initialize(format, localtime)
  @tc1 = 0
  @tc1_str = nil
  @tc2 = 0
  @tc2_str = nil

  if format
    if localtime
      define_singleton_method(:format_nocache) {|time|
        Time.at(time).strftime(format)
      }
    else
      define_singleton_method(:format_nocache) {|time|
        Time.at(time).utc.strftime(format)
      }
    end
  else
    if localtime
      define_singleton_method(:format_nocache) {|time|
        Time.at(time).iso8601
      }
    else
      define_singleton_method(:format_nocache) {|time|
        Time.at(time).utc.iso8601
      }
    end
  end
end

Public Instance Methods

format(time) click to toggle source
# File lib/fluent/mixin.rb, line 49
def format(time)
  if @tc1 == time
    return @tc1_str
  elsif @tc2 == time
    return @tc2_str
  else
    str = format_nocache(time)
    if @tc1 < @tc2
      @tc1 = time
      @tc1_str = str
    else
      @tc2 = time
      @tc2_str = str
    end
    return str
  end
end
format_nocache(time) click to toggle source
# File lib/fluent/mixin.rb, line 67
def format_nocache(time)
  # will be overridden in initialize
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.