class Hulse::Utils

Public Class Methods

bill_url(congress, bill_number) click to toggle source
# 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) click to toggle source

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

# 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) click to toggle source
# 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