lib/bills.rb in my-congress-0.2.5 vs lib/bills.rb in my-congress-0.2.6

- old
+ new

@@ -1,16 +1,17 @@ +require 'pry' class Bills def initialize page = Nokogiri::HTML(open('https://www.govtrack.us/congress/bills/')) bill_array = [] bills = page.css("table.table tr") bill_each = page.css("table.table tr td") x = 3 - while x < (4 + (bills.length - 1) * 4) + while x < (4 + (bills.length - 1) * 4) && x < 20 bill_hash = { } bill_hash[:name] = bill_each[x].css("a").children.text bill_hash[:congress] = bill_each[x-1].css("div").children.children.text bill_hash[:bill_url] = bill_each[x].css("a")[0].attributes["href"].value bill_hash[:bill_page] = Nokogiri::HTML(open("https://www.govtrack.us#{bill_hash[:bill_url]}")) @@ -24,13 +25,18 @@ bill_output(bill_array) end def bill_output(bill_array) + #limit max bills shown to 5 bills + x = bill_array.length + if x > 5 + x = 5 + end system "clear" puts " " puts " " - puts "#{bill_array.length} bills and resolutions that are on the House and Senate calendars for the coming days: ".colorize(:blue) + puts "#{x} bills and resolutions that are on the House and Senate calendars for the coming days: ".colorize(:blue) puts " " puts "------------------------------------------------------------------------------------------" puts " " bill_array.each do |bill| if !bill.empty? || bill != nil \ No newline at end of file