Class: PaBillreader::Bill
- Inherits:
-
Object
- Object
- PaBillreader::Bill
- Defined in:
- lib/pa_billreader/bill.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#full_text_url ⇒ Object
Returns the value of attribute full_text_url.
-
#last_action ⇒ Object
Returns the value of attribute last_action.
-
#memo_url ⇒ Object
Returns the value of attribute memo_url.
-
#number ⇒ Object
Returns the value of attribute number.
-
#prime_sponsor ⇒ Object
Returns the value of attribute prime_sponsor.
-
#short_title ⇒ Object
Returns the value of attribute short_title.
Class Method Summary collapse
- .all ⇒ Object
- .create_from_array(array) ⇒ Object
- .find_by_number(number, branch) ⇒ Object
- .house_bills ⇒ Object
- .senate_bills ⇒ Object
- .size ⇒ Object
- .sorted! ⇒ Object
Instance Method Summary collapse
- #add_bill_attributes(attr_hash) ⇒ Object
-
#initialize(bill_hash) ⇒ Bill
constructor
A new instance of Bill.
- #save ⇒ Object
Constructor Details
#initialize(bill_hash) ⇒ Bill
Returns a new instance of Bill.
7 8 9 10 11 12 |
# File 'lib/pa_billreader/bill.rb', line 7 def initialize(bill_hash) bill_hash.each { |attr, value| self.send("#{attr}=", value) } save end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def branch @branch end |
#full_text_url ⇒ Object
Returns the value of attribute full_text_url.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def full_text_url @full_text_url end |
#last_action ⇒ Object
Returns the value of attribute last_action.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def last_action @last_action end |
#memo_url ⇒ Object
Returns the value of attribute memo_url.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def memo_url @memo_url end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def number @number end |
#prime_sponsor ⇒ Object
Returns the value of attribute prime_sponsor.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def prime_sponsor @prime_sponsor end |
#short_title ⇒ Object
Returns the value of attribute short_title.
3 4 5 |
# File 'lib/pa_billreader/bill.rb', line 3 def short_title @short_title end |
Class Method Details
.all ⇒ Object
14 15 16 |
# File 'lib/pa_billreader/bill.rb', line 14 def self.all @@all end |
.create_from_array(array) ⇒ Object
31 32 33 34 35 |
# File 'lib/pa_billreader/bill.rb', line 31 def self.create_from_array(array) array.each { |bill_hash| PaBillreader::Bill.new(bill_hash) } end |
.find_by_number(number, branch) ⇒ Object
43 44 45 46 |
# File 'lib/pa_billreader/bill.rb', line 43 def self.find_by_number(number, branch) self.all.detect { |bill| bill.number == number && bill.branch == branch } end |
.house_bills ⇒ Object
48 49 50 |
# File 'lib/pa_billreader/bill.rb', line 48 def self.house_bills self.all.select {|bill| bill.branch == "H" } end |
.senate_bills ⇒ Object
52 53 54 |
# File 'lib/pa_billreader/bill.rb', line 52 def self.senate_bills self.all.select {|bill| bill.branch == "S" } end |
.size ⇒ Object
18 19 20 |
# File 'lib/pa_billreader/bill.rb', line 18 def self.size @@all.size end |
.sorted! ⇒ Object
26 27 28 29 |
# File 'lib/pa_billreader/bill.rb', line 26 def self.sorted! @@all.sort_by! {|bill| bill.number.to_i } end |
Instance Method Details
#add_bill_attributes(attr_hash) ⇒ Object
37 38 39 40 41 |
# File 'lib/pa_billreader/bill.rb', line 37 def add_bill_attributes(attr_hash) attr_hash.each { |attr, value| self.send("#{attr}=",value) } end |
#save ⇒ Object
22 23 24 |
# File 'lib/pa_billreader/bill.rb', line 22 def save @@all << self end |