Class: UkParliament::Parliament

Inherits:
Object
  • Object
show all
Includes:
UkParliament
Defined in:
lib/uk_parliament.rb

Overview

Class representing Parliament.

Constant Summary

Constants included from UkParliament

DATA_SOURCE_FILE, DATA_SOURCE_HTTP, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UkParliament

#configuration, configuration, log, #log

Constructor Details

#initialize(load_commons_file = true, load_lords_file = true) ⇒ Parliament

Initialise the class instance variables.



71
72
73
74
75
76
# File 'lib/uk_parliament.rb', line 71

def initialize(load_commons_file = true, load_lords_file = true)
  @houses = {
    :commons => Commons.new(load_commons_file),
    :lords => Lords.new(load_lords_file)
  }
end

Instance Attribute Details

#housesObject (readonly)

Instance data accessor(s).



68
69
70
# File 'lib/uk_parliament.rb', line 68

def houses
  @houses
end

Instance Method Details

#parliamentarians_named(search_name) ⇒ Object

Simple lookup of members with a particular name (or part of).



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/uk_parliament.rb', line 79

def parliamentarians_named(search_name)
  search_name = search_name.strip.downcase
  results = []

  if search_name.size > 1
    @houses.each_value { |house_data|
      house_data.members.each { |member|
        if member.key?('name')
          if member['name']['full_name'].downcase.include?(search_name)
            results << member
          end
        end
      }
    }
  end

  results
end