Class: GroongaDelta::LocalReader

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga-delta/local-reader.rb

Defined Under Namespace

Modules: Loggable Classes: PackedSchemaTarget, PackedTableTarget, SchemaTarget, TableTarget

Instance Method Summary collapse

Constructor Details

#initialize(logger, dir) ⇒ LocalReader

Returns a new instance of LocalReader.



25
26
27
28
# File 'lib/groonga-delta/local-reader.rb', line 25

def initialize(logger, dir)
  @logger = logger
  @dir = dir
end

Instance Method Details

#build_time(year, month, day, hour = 0, minute = 0, second = 0, nanosecond = 0) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/groonga-delta/local-reader.rb', line 39

def build_time(year, month, day, hour=0, minute=0, second=0, nanosecond=0)
  Time.utc(year,
           month,
           day,
           hour,
           minute,
           Rational(second * 1_000_000_000 + nanosecond,
                    1_000_000_000))
end

#each(min_timestamp = nil, max_timestamp = nil, &block) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/groonga-delta/local-reader.rb', line 30

def each(min_timestamp=nil, max_timestamp=nil, &block)
  unless block_given?
    return to_enum(__method__, min_timestamp, max_timestamp)
  end

  targets = list_targets(@dir, min_timestamp, max_timestamp)
  targets.sort_by(&:timestamp).each(&block)
end