Class: Confidence::Vote
- Inherits:
-
Object
- Object
- Confidence::Vote
- Defined in:
- lib/confidence.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#number ⇒ Object
Returns the value of attribute number.
-
#parliament ⇒ Object
Returns the value of attribute parliament.
-
#session ⇒ Object
Returns the value of attribute session.
Class Method Summary collapse
Instance Method Summary collapse
- #bill ⇒ Object
- #context ⇒ Object
- #decision ⇒ Object
-
#initialize(attrs = {}) ⇒ Vote
constructor
A new instance of Vote.
- #participants ⇒ Object
- #sponsor ⇒ Object
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
#doc ⇒ Object
Returns the value of attribute doc.
20 21 22 |
# File 'lib/confidence.rb', line 20 def doc @doc end |
#number ⇒ Object
Returns the value of attribute number.
19 20 21 |
# File 'lib/confidence.rb', line 19 def number @number end |
#parliament ⇒ Object
Returns the value of attribute parliament.
19 20 21 |
# File 'lib/confidence.rb', line 19 def parliament @parliament end |
#session ⇒ Object
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
#bill ⇒ Object
45 46 47 |
# File 'lib/confidence.rb', line 45 def bill Bill.new(@doc['RelatedBill']) end |
#context ⇒ Object
33 34 35 |
# File 'lib/confidence.rb', line 33 def context @doc['Context']['Para'] end |
#decision ⇒ Object
29 30 31 |
# File 'lib/confidence.rb', line 29 def decision @doc['Decision'] end |
#participants ⇒ Object
41 42 43 |
# File 'lib/confidence.rb', line 41 def participants @doc['Participant'].map {|p| Participant.new(p) } end |
#sponsor ⇒ Object
37 38 39 |
# File 'lib/confidence.rb', line 37 def sponsor @doc['Sponsor'] end |