class Object

Public Instance Methods

match_by_geo(info, query) click to toggle source

conditions are anded. no conditions == true

# File apache-log-geo, line 8
def match_by_geo info, query
  query.each do |k,v|
    if k == :eu                 # --eu is a boolean
      return false unless info[k]
    end

    if k == :subdivisions # it's an array, one match of its elements is enough
      return false unless (info[k] || []).any? {|val| val.to_s =~ /#{v}/i }
    end

    return false unless info[k].to_s =~ /#{v}/i
  end

  true
end