Class: RKD::Place
- Inherits:
-
Object
- Object
- RKD::Place
- Defined in:
- lib/r_k_d/place.rb
Instance Attribute Summary collapse
-
#geoname_id ⇒ Object
readonly
Returns the value of attribute geoname_id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lon ⇒ Object
readonly
Returns the value of attribute lon.
-
#refs ⇒ Object
readonly
Returns the value of attribute refs.
Instance Method Summary collapse
-
#initialize(label:, geoname_id: nil, point: nil, refs: [], lat: nil, lon: nil) ⇒ Place
constructor
A new instance of Place.
- #nilly? ⇒ Boolean
Constructor Details
#initialize(label:, geoname_id: nil, point: nil, refs: [], lat: nil, lon: nil) ⇒ Place
Returns a new instance of Place.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/r_k_d/place.rb', line 9 def initialize(label:, geoname_id: nil, point: nil, refs: [], lat: nil, lon: nil) @lon, @lat = parse_point(point).values if point @lat ||= lat @lon ||= lon @geoname_id = Integer(geoname_id) if geoname_id @refs = refs.compact geoname_ref = @refs.find { |ref| ref.start_with?("https://sws.geonames.org/") }&.sub("https://sws.geonames.org/", "") @geoname_id ||= Integer(geoname_ref) if geoname_ref @label = label end |
Instance Attribute Details
#geoname_id ⇒ Object (readonly)
Returns the value of attribute geoname_id.
3 4 5 |
# File 'lib/r_k_d/place.rb', line 3 def geoname_id @geoname_id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/r_k_d/place.rb', line 4 def label @label end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
5 6 7 |
# File 'lib/r_k_d/place.rb', line 5 def lat @lat end |
#lon ⇒ Object (readonly)
Returns the value of attribute lon.
6 7 8 |
# File 'lib/r_k_d/place.rb', line 6 def lon @lon end |
#refs ⇒ Object (readonly)
Returns the value of attribute refs.
7 8 9 |
# File 'lib/r_k_d/place.rb', line 7 def refs @refs end |
Instance Method Details
#nilly? ⇒ Boolean
21 22 23 |
# File 'lib/r_k_d/place.rb', line 21 def nilly? geoname_id.nil? && label.nil? && lat.nil? && lon.nil? && refs.empty? end |