Class: Hdo::StortingImporter::CommitteeMembership
- Inherits:
-
Object
- Object
- Hdo::StortingImporter::CommitteeMembership
- Includes:
- HasJsonSchema, IvarEquality
- Defined in:
- lib/hdo/storting_importer/committee_membership.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(external_id, start_date, end_date) ⇒ CommitteeMembership
constructor
A new instance of CommitteeMembership.
- #to_hash ⇒ Object
Methods included from IvarEquality
Methods included from HasJsonSchema
#as_json, included, schemas, #to_json, #valid?, #validate!
Constructor Details
#initialize(external_id, start_date, end_date) ⇒ CommitteeMembership
Returns a new instance of CommitteeMembership.
30 31 32 33 34 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 30 def initialize(external_id, start_date, end_date) @external_id = external_id @start_date = start_date @end_date = end_date end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
28 29 30 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 28 def end_date @end_date end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
28 29 30 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 28 def external_id @external_id end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
28 29 30 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 28 def start_date @start_date end |
Class Method Details
.example(overrides = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 10 def self.example(overrides = nil) obj = new 'ARBSOS', Date.parse("2009-09-01"), Date.parse("2013-08-01") if overrides obj = from_hash(obj.to_hash.merge(overrides)) end obj end |
.from_hash(hash) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 20 def self.from_hash(hash) binding.pry unless Hash === hash new hash['external_id'], (Date.parse(hash['start_date']) if hash['start_date']), (Date.parse(hash['end_date']) if hash['end_date']) end |
Instance Method Details
#to_hash ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/hdo/storting_importer/committee_membership.rb', line 36 def to_hash { 'kind' => self.class.kind, 'external_id' => external_id, 'start_date' => (start_date.strftime("%Y-%m-%d") if start_date), 'end_date' => (end_date.strftime("%Y-%m-%d") if end_date) } end |