Class: INE::Places::Place

Inherits:
OpenStruct
  • Object
show all
Includes:
CSVRecord
Defined in:
lib/ine/places/place.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CSVRecord

#to_param

Class Method Details

.find_all_by_province_id(province_id) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
# File 'lib/ine/places/place.rb', line 4

def self.find_all_by_province_id(province_id)
  raise ArgumentError if province_id.blank?

  collection_klass.records.select{ |place| place.province_id == province_id }
end

.find_by_name_and_province_id(place_name, province_id) ⇒ Object

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/ine/places/place.rb', line 10

def self.find_by_name_and_province_id(place_name, province_id)
  raise ArgumentError if place_name.blank? || province_id.blank?

  collection_klass.records.select{ |place| place.name == place_name && place.province_id == province_id.to_s }.first
end

Instance Method Details

#dataObject



16
17
18
# File 'lib/ine/places/place.rb', line 16

def data
  @data ||= OpenStruct.new
end