Module: Selectors::Firefly

Included in:
Firefly
Defined in:
lib/teecket/selectors/firefly.rb

Instance Method Summary collapse

Instance Method Details

#arrive_at_selector(flight) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/teecket/selectors/firefly.rb', line 11

def arrive_at_selector(flight)
  value = flight
          .css("td")[1]
          .css("div")[1]

  time_formatter(value)
end

#depart_at_selector(flight) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/teecket/selectors/firefly.rb', line 3

def depart_at_selector(flight)
  value = flight
          .css("td")[1]
          .css("div")[0]

  time_formatter(value)
end

#fare_selector(flight) ⇒ Object



19
20
21
22
23
24
# File 'lib/teecket/selectors/firefly.rb', line 19

def fare_selector(flight)
  value = flight
          .css("td")[2]
          .css("div")[1]
          .text
end

#flight_number_selector(flight) ⇒ Object



26
27
28
29
30
# File 'lib/teecket/selectors/firefly.rb', line 26

def flight_number_selector(flight)
  value = flight
          .css("td")[0]
          .text
end

#origin_destination_selector(html) ⇒ Object



32
33
34
35
# File 'lib/teecket/selectors/firefly.rb', line 32

def origin_destination_selector(html)
  text = html.css('form > div')[1].text
  text.scan(/[A-Z]{3}/)
end

#time_formatter(element) ⇒ Object



38
39
40
41
# File 'lib/teecket/selectors/firefly.rb', line 38

def time_formatter(element)
  DateTime.strptime(element.text, "%l:%M%p")
          .strftime("%I:%M %p")
end