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


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

def initialize(popolo)
  @popolo = popolo
end

Instance Attribute Details

#popoloObject (readonly)

Returns the value of attribute popolo


22
23
24
# File 'lib/everypolitician/popolo.rb', line 22

def popolo
  @popolo
end

Instance Method Details

#areasObject


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

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

#electionsObject


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

def elections
  @elections ||= events.elections
end

#eventsObject


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

def events  # do the sorting at the popolo level so we still get an Events object back

  @events ||= Events.new(popolo[:events].to_a.sort_by { |e| e[:start_date] }, self)
end

#latest_legislative_periodObject Also known as: latest_term, current_legislative_period, current_term


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

def latest_legislative_period
  legislative_periods.max_by(&:start_date)
end

#legislative_periodsObject Also known as: terms


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

def legislative_periods
  @legislative_periods ||= events.legislative_periods
end

#membershipsObject


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

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

#organizationsObject


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

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

#personsObject


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

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

#postsObject


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

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