Class: Watchmob::AukroPage

Inherits:
Page
  • Object
show all
Defined in:
lib/watchmob/aukro_page.rb

Instance Attribute Summary

Attributes inherited from Page

#document, #uri

Instance Method Summary collapse

Methods inherited from Page

#initialize

Constructor Details

This class inherits a constructor from Watchmob::Page

Instance Method Details

#deadlineObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/watchmob/aukro_page.rb', line 17

def deadline
  document.at_css(".timeInfo").inner_text.match(
    /\(([[:alpha:]]+),\s+(\d+)\s+([[:alpha:]]+),\s+(\d+):(\d+):(\d+)/
    ) do |md|
      text, weekday_name, month_day, month_name, hours, minutes, seconds = *md.to_a
      DateTime.new(
        Time.now.year,
        month_name_to_number(month_name),
        month_day.to_i,
        hours.to_i,
        minutes.to_i,
        seconds.to_i,
        '+1'
      )
  end
end

#finished?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/watchmob/aukro_page.rb', line 4

def finished?
  not document.at_css("#itemFinishBox2").nil?
end

#month_name_to_number(month_name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/watchmob/aukro_page.rb', line 34

def month_name_to_number(month_name)
  case month_name
  when "ledna" then 1
  when "února" then 2
  when "března" then 3
  when "dubna" then 4
  when "května" then 5
  when "června" then 6
  when "července" then 7
  when "srpna" then 8
  when "září" then 9
  when "října" then 10
  when "listopadu" then 11
  when "prosince" then 12
  else
    require 'pry'
    pry binding
    raise AukroDateError, "Unknown month name #{month_name.inspect}"
  end
end

#priceObject



8
9
10
11
12
13
14
15
# File 'lib/watchmob/aukro_page.rb', line 8

def price
  if finished?
    e = document.at_css("#itemFinishBox2 .left:first-child strong")
  else
    e = document.at_css(".price")
  end
  e.inner_text.gsub(/\s+/, "").gsub(",", ".").to_f
end