class Hulse::Record

Attributes

date[R]
html[R]
section[R]
topics[R]

Public Class Methods

base_url(date=nil) click to toggle source
# File lib/hulse/record.rb, line 16
def self.base_url(date=nil)
  if date
    year, month, day = date.year, date.month, date.day
  else
    date = Date.today-1
    year, month, day = date.year, date.month, date.day
  end
  "https://www.congress.gov/congressional-record/#{year}/#{month}/#{day}/"
end
create_from_html(html, date, section) click to toggle source
# File lib/hulse/record.rb, line 47
def self.create_from_html(html, date, section)
  section_topics = topics(html)
  self.new(date: date,
    section: section,
    topics: section_topics,
    html: html
  )
end
daily_digest(date=nil) click to toggle source
# File lib/hulse/record.rb, line 26
def self.daily_digest(date=nil)
  doc = HTTParty.get(base_url(date)+'daily-digest')
  html = Nokogiri::HTML(doc.parsed_response)
  (html/:pre).text
end
extension_of_remarks(date=nil) click to toggle source
# File lib/hulse/record.rb, line 42
def self.extension_of_remarks(date=nil)
  doc = HTTParty.get(base_url(date)+'extensions-of-remarks-section')
  create_from_html(Nokogiri::HTML(doc.parsed_response), date, 'extension')
end
house(date=nil) click to toggle source
# File lib/hulse/record.rb, line 37
def self.house(date=nil)
  doc = HTTParty.get(base_url(date)+'house-section')
  create_from_html(Nokogiri::HTML(doc.parsed_response), date, 'house')
end
new(params={}) click to toggle source
# File lib/hulse/record.rb, line 6
def initialize(params={})
  params.each_pair do |k,v|
    instance_variable_set("@#{k}", v)
  end
end
senate(date=nil) click to toggle source
# File lib/hulse/record.rb, line 32
def self.senate(date=nil)
  doc = HTTParty.get(base_url(date)+'senate-section')
  create_from_html(Nokogiri::HTML(doc.parsed_response), date, 'senate')
end
topics(html) click to toggle source
# File lib/hulse/record.rb, line 56
def self.topics(html)
  (html/:td).map{|d| d.children[1]}.compact.map{|l| {url: l['href'], title: l.text.strip}}
end

Public Instance Methods

chairman_designations() click to toggle source
# File lib/hulse/record.rb, line 88
def chairman_designations
  topics.select{|l| l[:title].include?("DESIGNATING THE CHAIRMAN")}
end
committee_elections() click to toggle source
# File lib/hulse/record.rb, line 80
def committee_elections
  topics.select{|l| l[:title].include?("COMMITTEE ELECTION")}
end
committee_leaves_of_absence() click to toggle source
# File lib/hulse/record.rb, line 100
def committee_leaves_of_absence
  topics.select{|l| l[:title].include?("COMMITTEE LEAVE OF ABSENCE")}
end
has_committee_elections?() click to toggle source
# File lib/hulse/record.rb, line 76
def has_committee_elections?
  topics.select{|l| l[:title].include?("COMMITTEE ELECTION")}.empty? ? false : true
end
has_committee_resignations?() click to toggle source
# File lib/hulse/record.rb, line 84
def has_committee_resignations?
  topics.select{|l| l[:title].include?("COMMITTEE RESIGNATION")}.empty? ? false : true
end
has_personal_explanations?() click to toggle source
# File lib/hulse/record.rb, line 68
def has_personal_explanations?
  topics.select{|l| l[:title].include?("PERSONAL EXPLANATION")}.empty? ? false : true
end
has_senate_explanations?() click to toggle source
# File lib/hulse/record.rb, line 60
def has_senate_explanations?
  topics.select{|l| l[:title].include?("VOTE EXPLANATION")}.empty? ? false : true
end
leaves_of_absence() click to toggle source
# File lib/hulse/record.rb, line 96
def leaves_of_absence
  topics.select{|l| l[:title].include?("LEAVE OF ABSENCE")}
end
personal_explanations() click to toggle source
# File lib/hulse/record.rb, line 72
def personal_explanations
  topics.select{|l| l[:title].include?("PERSONAL EXPLANATION")}
end
ranking_designations() click to toggle source
# File lib/hulse/record.rb, line 92
def ranking_designations
  topics.select{|l| l[:title].include?("DESIGNATING THE RANKING")}
end
senate_explanations() click to toggle source
# File lib/hulse/record.rb, line 64
def senate_explanations
  topics.select{|l| l[:title].include?("VOTE EXPLANATION")}
end
to_s() click to toggle source
# File lib/hulse/record.rb, line 12
def to_s
  section
end