Class: Hulse::Utils

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

Class Method Summary collapse

Class Method Details

.bill_url(congress, bill_number) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/hulse.rb', line 30

def self.bill_url(congress, bill_number)
  bill_title = bill_number.scan(/[A-Z]+/).join.upcase
  if bill_title == 'HR'
    bt = 'house-bill'
  elsif bill_title == 'HRES'
    bt = 'house-resolution'
  elsif bill_title == 'HJRES'
    bt = 'house-joint-resolution'
  elsif bill_title == 'S'
    bt = 'senate-bill'
  elsif bill_title == 'SRES'
    bt = 'senate-resolution'
  elsif bill_title == 'SJRES'
    bt = 'senate-joint-resolution'
  end
  bill_num = bill_number.scan(/\d/).join
  "https://www.congress.gov/bill/#{congress.to_i.ordinalize.to_s}-congress/#{bt}/#{bill_num}"
end

.congress_for_year(year) ⇒ Object

this function is more intuitive when you solve for the other side: year = 1789 + (2 * (congress - 1))



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

def self.congress_for_year(year)
  ((year.to_i + 1) / 2) - 894
end

.convert_year_to_congress_and_session(year) ⇒ Object



24
25
26
27
28
# File 'lib/hulse.rb', line 24

def self.convert_year_to_congress_and_session(year)
  congress = congress_for_year year
  session = year.to_i.odd? ? 1 : 2
  return [congress, session]
end