Class: Everypolitician::LegislativePeriod
- Inherits:
-
Object
- Object
- Everypolitician::LegislativePeriod
- Defined in:
- lib/everypolitician/legislative_period.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#csv_url ⇒ Object
readonly
Returns the value of attribute csv_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#legislature ⇒ Object
readonly
Returns the value of attribute legislature.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #csv ⇒ Object
- #end_date ⇒ Object
-
#initialize(legislative_period_data, legislature, country) ⇒ LegislativePeriod
constructor
A new instance of LegislativePeriod.
- #start_date ⇒ Object
Constructor Details
#initialize(legislative_period_data, legislature, country) ⇒ LegislativePeriod
Returns a new instance of LegislativePeriod.
14 15 16 17 18 19 20 21 22 |
# File 'lib/everypolitician/legislative_period.rb', line 14 def initialize(legislative_period_data, legislature, country) @id = legislative_period_data[:id] @name = legislative_period_data[:name] @slug = legislative_period_data[:slug] @csv_url = legislative_period_data[:csv_url] @legislature = legislature @country = country @raw_data = legislative_period_data end |
Instance Attribute Details
#country ⇒ Object (readonly)
Returns the value of attribute country.
10 11 12 |
# File 'lib/everypolitician/legislative_period.rb', line 10 def country @country end |
#csv_url ⇒ Object (readonly)
Returns the value of attribute csv_url.
12 13 14 |
# File 'lib/everypolitician/legislative_period.rb', line 12 def csv_url @csv_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/everypolitician/legislative_period.rb', line 6 def id @id end |
#legislature ⇒ Object (readonly)
Returns the value of attribute legislature.
9 10 11 |
# File 'lib/everypolitician/legislative_period.rb', line 9 def legislature @legislature end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/everypolitician/legislative_period.rb', line 7 def name @name end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
11 12 13 |
# File 'lib/everypolitician/legislative_period.rb', line 11 def raw_data @raw_data end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
8 9 10 |
# File 'lib/everypolitician/legislative_period.rb', line 8 def slug @slug end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/everypolitician/legislative_period.rb', line 36 def [](key) raw_data[key] end |
#csv ⇒ Object
32 33 34 |
# File 'lib/everypolitician/legislative_period.rb', line 32 def csv CSV.parse(open(csv_url).read, headers: true, header_converters: :symbol, converters: nil) end |
#end_date ⇒ Object
28 29 30 |
# File 'lib/everypolitician/legislative_period.rb', line 28 def end_date @end_date ||= parse_partial_date(raw_data[:end_date]) end |
#start_date ⇒ Object
24 25 26 |
# File 'lib/everypolitician/legislative_period.rb', line 24 def start_date @start_date ||= parse_partial_date(raw_data[:start_date]) end |