Class: Confidence::Vote

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Vote

Returns a new instance of Vote.



22
23
24
25
26
27
# File 'lib/confidence.rb', line 22

def initialize(attrs={})
  @parliament = attrs[:parliament]
  @session    = attrs[:session]
  @number     = attrs[:number]
  @doc        = attrs[:doc]
end

Instance Attribute Details

#docObject

Returns the value of attribute doc.



20
21
22
# File 'lib/confidence.rb', line 20

def doc
  @doc
end

#numberObject

Returns the value of attribute number.



19
20
21
# File 'lib/confidence.rb', line 19

def number
  @number
end

#parliamentObject

Returns the value of attribute parliament.



19
20
21
# File 'lib/confidence.rb', line 19

def parliament
  @parliament
end

#sessionObject

Returns the value of attribute session.



19
20
21
# File 'lib/confidence.rb', line 19

def session
  @session
end

Class Method Details

.fetch(attrs = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/confidence.rb', line 7

def self.fetch(attrs={})
  vote = new(attrs)

  # Parl= and FltrParl= are redundant. Contact your local mp to complain if you care.
  doc = HTTParty.get(
    "http://www2.parl.gc.ca/HouseChamberBusiness/Chambervotedetail.aspx?Language=E&Mode=1&Parl=#{vote.parliament}&Ses=#{vote.session}&FltrParl=#{vote.parliament}&FltrSes=#{vote.session}&vote=#{vote.number}&xml=True"
  )

  vote.doc = doc['Vote']
  vote
end

Instance Method Details

#billObject



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

def bill
  Bill.new(@doc['RelatedBill'])
end

#contextObject



33
34
35
# File 'lib/confidence.rb', line 33

def context
  @doc['Context']['Para']
end

#decisionObject



29
30
31
# File 'lib/confidence.rb', line 29

def decision
  @doc['Decision']
end

#participantsObject



41
42
43
# File 'lib/confidence.rb', line 41

def participants
  @doc['Participant'].map {|p| Participant.new(p) }
end


37
38
39
# File 'lib/confidence.rb', line 37

def sponsor
  @doc['Sponsor']
end