class Udger::BaseParser

Attributes

db[RW]

Public Class Methods

new(db) click to toggle source
# File lib/udger/base_parser.rb, line 5
def initialize(db)
  @db = db
end

Protected Instance Methods

regexp(string) click to toggle source
# File lib/udger/base_parser.rb, line 11
def regexp(string)
  r1 = string.index('/')
  r2 = string.length - string.reverse.index('/') - 1
  Regexp.new string[r1 + 1..r2 - 1], true
end
regexp_parse(query, _cache = true) { |match, row| ... } click to toggle source
# File lib/udger/base_parser.rb, line 17
def regexp_parse(query, _cache = true)
  db.execute(query) do |row|
    match = ua_string.scan(regexp(row['regstring']))
    unless match.empty?
      yield match, row
      break
    end
  end
end