Class: Vatbook::Booking

Inherits:
Object
  • Object
show all
Defined in:
lib/vatbook/booking.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(booking, role, fir) ⇒ Booking

Returns a new instance of Booking.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vatbook/booking.rb', line 9

def initialize(booking, role, fir)
  @fir = fir
  @role = role
  @callsign = booking.children.css("callsign").first.children.to_s
  @name = booking.children.css("name").first.children.to_s
  @role == "atc" ? @cid = booking.children.css("cid").first.children.to_s : @cid = booking.children.css("pid").first.children.to_s
  if @role == "atc"
    @start = booking.children.css("time_start").first.children.to_s
    @end = booking.children.css("time_end").first.children.to_s
  elsif @role == "pilot"
    @dep = booking.children.css("dep").first.children.to_s
    @arr = booking.children.css("arr").first.children.to_s
    @route = booking.children.css("route").first.children.to_s.gsub(/[\n]/, ' ').strip
    @start = booking.children.css("from").first.children.to_s
    @end = booking.children.css("to").first.children.to_s
    @aircraft = booking.children.css("actype").first.children.to_s
    check_enroute
  end
end

Instance Attribute Details

#aircraftObject

Returns the value of attribute aircraft.



7
8
9
# File 'lib/vatbook/booking.rb', line 7

def aircraft
  @aircraft
end

#arrObject

Returns the value of attribute arr.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def arr
  @arr
end

#callsignObject

Returns the value of attribute callsign.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def callsign
  @callsign
end

#cidObject

Returns the value of attribute cid.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def cid
  @cid
end

#depObject

Returns the value of attribute dep.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def dep
  @dep
end

#endObject

Returns the value of attribute end.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def end
  @end
end

#enrouteObject

Returns the value of attribute enroute.



7
8
9
# File 'lib/vatbook/booking.rb', line 7

def enroute
  @enroute
end

#firObject

Returns the value of attribute fir.



7
8
9
# File 'lib/vatbook/booking.rb', line 7

def fir
  @fir
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def name
  @name
end

#roleObject

Returns the value of attribute role.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def role
  @role
end

#routeObject

Returns the value of attribute route.



7
8
9
# File 'lib/vatbook/booking.rb', line 7

def route
  @route
end

#startObject

Returns the value of attribute start.



6
7
8
# File 'lib/vatbook/booking.rb', line 6

def start
  @start
end