Class: Everypolitician::Popolo::JSON

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(popolo) ⇒ JSON

Returns a new instance of JSON.



28
29
30
# File 'lib/everypolitician/popolo.rb', line 28

def initialize(popolo)
  @popolo = popolo
end

Instance Attribute Details

#popoloObject (readonly)

Returns the value of attribute popolo.



26
27
28
# File 'lib/everypolitician/popolo.rb', line 26

def popolo
  @popolo
end

Instance Method Details

#areasObject



40
41
42
# File 'lib/everypolitician/popolo.rb', line 40

def areas
  Areas.new(popolo[:areas], self)
end

#current_legislative_periodObject Also known as: current_term



61
62
63
# File 'lib/everypolitician/popolo.rb', line 61

def current_legislative_period
  legislative_periods.last
end

#eventsObject



44
45
46
# File 'lib/everypolitician/popolo.rb', line 44

def events
  Events.new(popolo[:events], self)
end

#legislative_periodsObject Also known as: terms



56
57
58
# File 'lib/everypolitician/popolo.rb', line 56

def legislative_periods
  events.where(classification: 'legislative period').sort_by(&:start_date)
end

#membershipsObject



52
53
54
# File 'lib/everypolitician/popolo.rb', line 52

def memberships
  Memberships.new(popolo[:memberships], self)
end

#organizationsObject



36
37
38
# File 'lib/everypolitician/popolo.rb', line 36

def organizations
  Organizations.new(popolo[:organizations], self)
end

#personsObject



32
33
34
# File 'lib/everypolitician/popolo.rb', line 32

def persons
  People.new(popolo[:persons], self)
end

#postsObject



48
49
50
# File 'lib/everypolitician/popolo.rb', line 48

def posts
  Posts.new(popolo[:posts], self)
end