Class: Hdo::StortingImporter::District
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #__ivars__, #hash
#as_json, included, schemas, #to_json, #valid?, #validate!
Constructor Details
#initialize(external_id, name) ⇒ District
Returns a new instance of District.
37
38
39
40
|
# File 'lib/hdo/storting_importer/district.rb', line 37
def initialize(external_id, name)
@external_id = external_id
@name = name
end
|
Instance Attribute Details
#external_id ⇒ Object
Returns the value of attribute external_id.
7
8
9
|
# File 'lib/hdo/storting_importer/district.rb', line 7
def external_id
@external_id
end
|
#name ⇒ Object
Returns the value of attribute name.
7
8
9
|
# File 'lib/hdo/storting_importer/district.rb', line 7
def name
@name
end
|
Class Method Details
.example(overrides = nil) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/hdo/storting_importer/district.rb', line 12
def self.example(overrides = nil)
obj = new("Db", "Duckburg")
if overrides
obj = from_hash(obj.to_hash.merge(overrides))
end
obj
end
|
.from_hash(hash) ⇒ Object
33
34
35
|
# File 'lib/hdo/storting_importer/district.rb', line 33
def self.from_hash(hash)
new hash['external_id'], hash['name']
end
|
.from_storting_doc(doc) ⇒ Object
22
23
24
25
26
|
# File 'lib/hdo/storting_importer/district.rb', line 22
def self.from_storting_doc(doc)
doc.css("fylker_liste fylke").map do |node|
from_storting_node(node)
end
end
|
.from_storting_node(node) ⇒ Object
28
29
30
31
|
# File 'lib/hdo/storting_importer/district.rb', line 28
def self.from_storting_node(node)
new node.css("id").first.text,
node.css("navn").first.text
end
|
Instance Method Details
#to_hash ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/hdo/storting_importer/district.rb', line 42
def to_hash
{
'kind' => self.class.kind,
'external_id' => @external_id,
'name' => @name
}
end
|