Class: Martlet::TranscriptParser
- Inherits:
-
Object
- Object
- Martlet::TranscriptParser
- Defined in:
- lib/martlet/transcript_parser.rb
Instance Method Summary collapse
-
#initialize(html) ⇒ TranscriptParser
constructor
A new instance of TranscriptParser.
- #parse_records ⇒ Object
Constructor Details
#initialize(html) ⇒ TranscriptParser
Returns a new instance of TranscriptParser.
3 4 5 |
# File 'lib/martlet/transcript_parser.rb', line 3 def initialize(html) @html = html end |
Instance Method Details
#parse_records ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/martlet/transcript_parser.rb', line 7 def parse_records records = [] document = Nokogiri::HTML(@html) rows = document.search("table[@class='dataentrytable'] tr") rows.each do |row| row_data = row.search('td') next unless record_data_row?(row_data) && grade_present?(row_data) record_data = { number: extract_record_data_for(row_data, :number), name: extract_record_data_for(row_data, :name), section: extract_record_data_for(row_data, :section), credits: extract_record_data_for(row_data, :credits), grade: extract_record_data_for(row_data, :grade), average: extract_record_data_for(row_data, :average) } records << Record.new(record_data) end records end |