class FiasReader::Scope

Инерфейс для работы XML с базой ФИАС

Attributes

logics[R]
options[R]

Public Class Methods

new(table) click to toggle source
# File lib/fias_reader/scope.rb, line 6
def initialize(table)
  @table = table
  @options = {}
  @logics = @table.class::LOGICS.dup
end

Public Instance Methods

all() { |row| ... } click to toggle source
# File lib/fias_reader/scope.rb, line 12
def all
  @options[:rows] = -> (row) { yield row }
  parse!
end
default_parser() click to toggle source
# File lib/fias_reader/scope.rb, line 40
def default_parser
  FiasReader::Parser.new(logics, @options)
end
first() click to toggle source
# File lib/fias_reader/scope.rb, line 17
def first
  result = nil
  catch :fias_parse_stop do
    @options[:rows] = -> (row) do
      result = row
      throw :fias_parse_stop
    end
    parse!
  end
  result
end
parse!(parser = default_parser) click to toggle source
# File lib/fias_reader/scope.rb, line 36
def parse!(parser = default_parser)
  Ox.sax_parse parser, @table.file, symbolize: true
end
select(*args) click to toggle source
# File lib/fias_reader/scope.rb, line 29
def select(*args)
  index = @logics.index(FiasReader::ParseLogic::Attributes)
  @logics[index] = FiasReader::ParseLogic::AttributesSelect if index
  @options[:select] = args
  self
end