Class: Hdo::StortingImporter::Issue
- Inherits:
-
Object
- Object
- Hdo::StortingImporter::Issue
- Includes:
- HasJsonSchema, Inspectable, IvarEquality
- Defined in:
- lib/hdo/storting_importer/issue.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#committee ⇒ Object
readonly
Returns the value of attribute committee.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#document_group ⇒ Object
readonly
Returns the value of attribute document_group.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#last_update ⇒ Object
readonly
Returns the value of attribute last_update.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .example ⇒ Object
- .from_hash(hash) ⇒ Object
- .from_storting_doc(doc) ⇒ Object
- .from_storting_node(node) ⇒ Object
- .json_example ⇒ Object
Instance Method Summary collapse
-
#initialize(external_id, summary, description, type, status, last_update, reference, document_group, committee, categories) ⇒ Issue
constructor
A new instance of Issue.
- #short_inspect ⇒ Object
- #to_hash ⇒ Object
Methods included from Inspectable
Methods included from IvarEquality
Methods included from HasJsonSchema
#as_json, included, schemas, #to_json, #valid?, #validate!
Constructor Details
#initialize(external_id, summary, description, type, status, last_update, reference, document_group, committee, categories) ⇒ Issue
Returns a new instance of Issue.
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/hdo/storting_importer/issue.rb', line 76 def initialize(external_id, summary, description, type, status, last_update, reference, document_group, committee, categories) @external_id = external_id @summary = summary @description = description @type = type @status = status @last_update = last_update @reference = reference @document_group = document_group @committee = committee @categories = categories || [] end |
Instance Attribute Details
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def categories @categories end |
#committee ⇒ Object (readonly)
Returns the value of attribute committee.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def committee @committee end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def description @description end |
#document_group ⇒ Object (readonly)
Returns the value of attribute document_group.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def document_group @document_group end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def external_id @external_id end |
#last_update ⇒ Object (readonly)
Returns the value of attribute last_update.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def last_update @last_update end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def reference @reference end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def status @status end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def summary @summary end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/hdo/storting_importer/issue.rb', line 10 def type @type end |
Class Method Details
.example ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hdo/storting_importer/issue.rb', line 15 def self.example new( "53520", "InngÄelse av avtale om opprettelse av sekretariatet for Den nordlige dimensjons partnerskap for helse og livskvalitet (NDPHS)", "Samtykke til inngÄelse av avtale av 25. november 2011 om opprettelse av sekretariatet for Den nordlige dimensjons partnerskap for helse og livskvalitet (NDPHS)", "alminneligsak", "mottatt", "2012-04-20T00:00:00", "Prop. 90 S (2011-2012)", "proposisjon", "Transport- og kommunikasjonskomiteen", ['UTENRIKSSAKER', 'TRAKTATER', 'NORDISK SAMARBEID'] ) end |
.from_hash(hash) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hdo/storting_importer/issue.rb', line 63 def self.from_hash(hash) new hash['externalId'], hash['summary'], hash['description'], hash['type'], hash['status'], hash['lastUpdate'], hash['reference'], hash['documentGroup'], hash['committee'], hash['categories'] end |
.from_storting_doc(doc) ⇒ Object
34 35 36 37 38 |
# File 'lib/hdo/storting_importer/issue.rb', line 34 def self.from_storting_doc(doc) doc.css("saker_liste sak").map do |node| from_storting_node(node) end end |
.from_storting_node(node) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hdo/storting_importer/issue.rb', line 40 def self.from_storting_node(node) external_id = node.xpath("./id").first.text summary = node.css("korttittel").first.text description = Util.remove_newlines(node.css("tittel").first.text) type = node.css("type").first.text status = node.css("status").first.text last_update = node.css("sist_oppdatert_dato").first.text reference = node.css("henvisning").first.text document_group = node.css("dokumentgruppe").first.text committee_node = node.css("komite").first if committee_node && committee_node['nil'] != "true" committee = committee_node.css("navn").first.text end xcategories = node.css("emne") if xcategories.any? categories = xcategories.map { |xt| xt.css("navn").first.text } end new(external_id, summary, description, type, status, last_update, reference, document_group, committee, categories) end |
.json_example ⇒ Object
30 31 32 |
# File 'lib/hdo/storting_importer/issue.rb', line 30 def self.json_example Util.json_pretty example end |
Instance Method Details
#short_inspect ⇒ Object
90 91 92 |
# File 'lib/hdo/storting_importer/issue.rb', line 90 def short_inspect short_inspect_string :include => [:external_id, :summary] end |
#to_hash ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/hdo/storting_importer/issue.rb', line 94 def to_hash { 'kind' => self.class.kind, 'externalId' => @external_id, 'summary' => @summary, 'description' => @description, 'type' => @type, 'status' => @status, 'lastUpdate' => @last_update, 'reference' => @reference, 'documentGroup' => @document_group, 'committee' => @committee, 'categories' => @categories } end |