class Lakes::Texas::FishingReportParser
Attributes
date[R]
raw_date[R]
raw_text[R]
report[R]
Public Class Methods
new(text)
click to toggle source
# File lib/lakes/texas/fishing_report_parser.rb, line 12 def initialize(text) @raw_text = text @raw_date = nil @date = nil @report = nil parse end
Public Instance Methods
parse()
click to toggle source
# File lib/lakes/texas/fishing_report_parser.rb, line 20 def parse current_fishing_report_doc = Nokogiri::HTML(raw_text) current_fishing_report_dl = current_fishing_report_doc.at('div.row.report div.container dl') return if current_fishing_report_dl.nil? date_text = current_fishing_report_dl.at('dt span.title').try(:text) @raw_date = cleanup_data(date_text) unless date_text.nil? @date = Date.parse(@raw_date) rescue nil report_text = current_fishing_report_dl.xpath('dd').try(:text) @report = cleanup_data(report_text) unless report_text.nil? end