Class: RequestHistoryTable

Inherits:
Object
  • Object
show all
Defined in:
lib/trackit_scraper/2003.10.1/lib/request_history_table.rb

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ RequestHistoryTable

Returns a new instance of RequestHistoryTable.



5
6
7
# File 'lib/trackit_scraper/2003.10.1/lib/request_history_table.rb', line 5

def initialize(table)
  @table = table
end

Instance Method Details

#get_resolution_infoObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/trackit_scraper/2003.10.1/lib/request_history_table.rb', line 9

def get_resolution_info
  r = {}
  rows = @table.trs.to_a
  resolved_row_index = rows.index { |r| r.text =~ /Resolved by/ }

  if resolved_row_index
    row_above = rows[resolved_row_index-1]
    captures = row_above.text.scan(/(.+) by (.+)/)[0]
    r[:resolved_on] = Time.parse captures[0]
    r[:resolved_by] = captures[1]
  end

  r[:history] = @table.text
  r
end