class Andromeda::Kit::Targeting::FileReader

Attributes

mode[R]
path[R]

Public Class Methods

new(config = {}) click to toggle source
Calls superclass method
# File lib/andromeda/kit.rb, line 136
def initialize(config = {})
  super config
  @mode ||= init_mode
end

Public Instance Methods

data_tag(name, key, val, tags_in) click to toggle source
Calls superclass method
# File lib/andromeda/kit.rb, line 141
def data_tag(name, key, val, tags_in)
  tags_out         = super
  tags_out[:first] = val.first rescue 0
  tags_out[:last]  = val.last rescue -1
  tags_out
end
init_mode() click to toggle source
# File lib/andromeda/kit.rb, line 148
def init_mode ; 'r' end

Protected Instance Methods

on_enter(key, val) { |file else super key, val end| ... } click to toggle source
# File lib/andromeda/kit.rb, line 152
  def on_enter(key, val)
    file = File.open path, mode
    begin
        file.seek tags[:first]
        tags[:last] = file.size - 1 if tags[:last] < 0
        tags[:num]  = tags[:last] - tags[:first]
        if block_given? then yield file else super key, val end
    ensure
      file.close
    end
  end

end