Class: RKD::Place

Inherits:
Object
  • Object
show all
Defined in:
lib/r_k_d/place.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_idObject (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

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/r_k_d/place.rb', line 4

def label
  @label
end

#latObject (readonly)

Returns the value of attribute lat.



5
6
7
# File 'lib/r_k_d/place.rb', line 5

def lat
  @lat
end

#lonObject (readonly)

Returns the value of attribute lon.



6
7
8
# File 'lib/r_k_d/place.rb', line 6

def lon
  @lon
end

#refsObject (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

Returns:

  • (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