Class: PaBillreader::Bill

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

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#branchObject

Returns the value of attribute branch.



3
4
5
# File 'lib/pa_billreader/bill.rb', line 3

def branch
  @branch
end

#full_text_urlObject

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_actionObject

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_urlObject

Returns the value of attribute memo_url.



3
4
5
# File 'lib/pa_billreader/bill.rb', line 3

def memo_url
  @memo_url
end

#numberObject

Returns the value of attribute number.



3
4
5
# File 'lib/pa_billreader/bill.rb', line 3

def number
  @number
end

#prime_sponsorObject

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_titleObject

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

.allObject



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_billsObject



48
49
50
# File 'lib/pa_billreader/bill.rb', line 48

def self.house_bills
	self.all.select {|bill| bill.branch == "H" }
end

.senate_billsObject



52
53
54
# File 'lib/pa_billreader/bill.rb', line 52

def self.senate_bills
	self.all.select {|bill| bill.branch == "S" }
end

.sizeObject



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

#saveObject



22
23
24
# File 'lib/pa_billreader/bill.rb', line 22

def save
	@@all << self
end