Class: Geocodio::AddressSet
- Inherits:
-
Object
- Object
- Geocodio::AddressSet
- Includes:
- Enumerable
- Defined in:
- lib/geocodio/address_set.rb
Instance Attribute Summary collapse
-
#query ⇒ String
readonly
Returns the query that retrieved this result set.
Instance Method Summary collapse
-
#best ⇒ Geocodio::Address
Returns the result that geocod.io deemed the most accurate for the query.
- #each(&block) ⇒ Object
-
#empty? ⇒ Boolean
Returns whether or not there are any addresses in this result set.
-
#initialize(query, *addresses) ⇒ AddressSet
constructor
A new instance of AddressSet.
-
#size ⇒ Integer
Returns the number of addresses contained in this result set.
Constructor Details
#initialize(query, *addresses) ⇒ AddressSet
Returns a new instance of AddressSet.
14 15 16 17 |
# File 'lib/geocodio/address_set.rb', line 14 def initialize(query, *addresses) @query = query @addresses = addresses end |
Instance Attribute Details
#query ⇒ String (readonly)
Returns the query that retrieved this result set.
12 13 14 |
# File 'lib/geocodio/address_set.rb', line 12 def query @query end |
Instance Method Details
#best ⇒ Geocodio::Address
Returns the result that geocod.io deemed the most accurate for the query.
26 27 28 |
# File 'lib/geocodio/address_set.rb', line 26 def best max_by(&:accuracy) end |
#each(&block) ⇒ Object
19 20 21 |
# File 'lib/geocodio/address_set.rb', line 19 def each(&block) @addresses.each(&block) end |
#empty? ⇒ Boolean
Returns whether or not there are any addresses in this result set.
40 41 42 |
# File 'lib/geocodio/address_set.rb', line 40 def empty? @addresses.empty? end |
#size ⇒ Integer
Returns the number of addresses contained in this result set.
33 34 35 |
# File 'lib/geocodio/address_set.rb', line 33 def size @addresses.size end |