Sha256: d5825a772a133a152ead7d703bd14468f6a04fcc071cc44482d63944e166df4c
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 KB
Contents
# encoding: UTF-8 module Graticule # Used to compare the precision of different geocoded locations class Precision include Comparable attr_reader :name NAMES = [ :point, :unknown, :country, :region, :locality, :postal_code, :street, :address, :premise ] def initialize(name) @name = name.to_sym raise ArgumentError, "#{name} is not a valid precision. Use one of #{NAMES.inspect}" unless NAMES.include?(@name) end Unknown = Precision.new(:unknown) Point = Precision.new(:point) Country = Precision.new(:country) Region = Precision.new(:region) Locality = Precision.new(:locality) PostalCode = Precision.new(:postal_code) Street = Precision.new(:street) Address = Precision.new(:address) Premise = Precision.new(:premise) def to_s @name.to_s end def <=>(other) other = Precision.new(other) unless other.is_a?(Precision) NAMES.index(self.name) <=> NAMES.index(other.name) end def ==(other) (self <=> other) == 0 end end end
Version data entries
6 entries across 6 versions & 1 rubygems