Class: Everypolitician::LegislativePeriod

Inherits:
Object
  • Object
show all
Defined in:
lib/everypolitician/legislative_period.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countryObject (readonly)

Returns the value of attribute country.



10
11
12
# File 'lib/everypolitician/legislative_period.rb', line 10

def country
  @country
end

#csv_urlObject (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

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/everypolitician/legislative_period.rb', line 6

def id
  @id
end

#legislatureObject (readonly)

Returns the value of attribute legislature.



9
10
11
# File 'lib/everypolitician/legislative_period.rb', line 9

def legislature
  @legislature
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/everypolitician/legislative_period.rb', line 7

def name
  @name
end

#raw_dataObject (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

#slugObject (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

#csvObject



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_dateObject



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_dateObject



24
25
26
# File 'lib/everypolitician/legislative_period.rb', line 24

def start_date
  @start_date ||= parse_partial_date(raw_data[:start_date])
end