From 741f154229ef8a5376cdbfdc35ef31b33577c7f9 Mon Sep 17 00:00:00 2001 From: Tony Bowden Date: Mon, 6 Apr 2015 11:58:48 +0100 Subject: [PATCH] Remove all Helper methods --- lib/popolo_helper.rb | 46 +++++++------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/lib/popolo_helper.rb b/lib/popolo_helper.rb index 89dbeabae..a76265d14 100644 --- a/lib/popolo_helper.rb +++ b/lib/popolo_helper.rb @@ -1,5 +1,7 @@ module Popolo + require 'date' + class Data def initialize(file) @@ -35,6 +37,11 @@ def terms legislature['terms'] end + def legislative_memberships + # TODO expand! + memberships.find_all { |m| m['organization_id'] == 'legislature' } + end + def term_from_id(id) terms.detect { |t| t['id'] == id } || terms.detect { |t| t['id'].end_with? "/#{id}" } @@ -78,45 +85,6 @@ def party_memberships(id) module Helper - require 'date' - - def popit_data(file='eduskunta') - @_data ||= {} - @_data[file] ||= Popolo::Data.new(file).json - end - - def persons - popit_data['persons'] - end - - def organizations - popit_data['organizations'] - end - - def parties - popit_data['organizations'].find_all { |o| o['classification'] == 'party' } - end - - def legislature - # TODO cope with more than one! - popit_data['organizations'].find { |o| o['classification'] == 'legislature' } - end - - def terms - legislature['terms'] - end - - def memberships - popit_data['memberships'] - end - - def legislative_memberships - # TODO expand! - memberships.find_all { |m| m['organization_id'] == 'legislature' } - end - end end - -