class Parliamentarian::Australia::Victoria

Constants

LEGISLATIVE_ASSEMBLY_URL
LEGISLATIVE_COUNCIL_URL

Public Class Methods

all(legislative_councillors_csv_file_location = nil, legislative_assemblymembers_csv_file_location = nil) click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 26
def all(legislative_councillors_csv_file_location = nil, legislative_assemblymembers_csv_file_location = nil)
  @all ||= (legislative_councillors(legislative_councillors_csv_file_location) + legislative_assemblymembers(legislative_assemblymembers_csv_file_location)).flatten
end
fetch(csv_file_location) click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 17
def fetch(csv_file_location)
  raw_csv = if ['http', 'https'].include?(URI.parse(csv_file_location).scheme)
    URI.open(csv_file_location)
  else
    File.read(csv_file_location)
  end
  SimpleCSV.read(raw_csv, headers: true)
end
legislative_assemblymembers(csv_file_location = nil) click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 37
def legislative_assemblymembers(csv_file_location = nil)
  @legislative_assembly ||= (
    csv_file_location = csv_file_location || LEGISLATIVE_ASSEMBLY_URL
    fetch(csv_file_location).collect{|row| self.new(row)}
  )
end
legislative_councillors(csv_file_location = nil) click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 30
def legislative_councillors(csv_file_location = nil)
  @legislative_council ||= (
    csv_file_location = csv_file_location || LEGISLATIVE_COUNCIL_URL
    fetch(csv_file_location).collect{|row| self.new(row)}
  )
end
new(row) click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 46
def initialize(row)
  row.keys.each do |header|
    attr_name = self.attr_name(header)
    self.class.send(:attr_accessor, attr_name)
    self.send("#{attr_name}=", row[header])
  end
  extract_postcode_from_electorate_office_address
end

Public Instance Methods

first_name() click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 57
def first_name; preferred_name; end
firstname() click to toggle source

For consistency with Australia::Federal and vice-versa…

# File lib/Parliamentarian/Australia/Victoria.rb, line 56
def firstname; preferred_name; end
lastname() click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 59
def lastname; last_name; end
surname() click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 58
def surname; last_name; end

Private Instance Methods

attr_name(header) click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 63
def attr_name(header)
  header.underscore
end
extract_postcode_from_electorate_office_address() click to toggle source
# File lib/Parliamentarian/Australia/Victoria.rb, line 67
def extract_postcode_from_electorate_office_address
  self.class.send(:attr_accessor, 'postcode')
  self.postcode = eo_address.split.last
end