Class: StationData

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ StationData

Returns a new instance of StationData.



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

def initialize hash
  @servertime       = hash['Servertime']
  @traincode        = hash['Traincode']
  @station_name     = hash['Stationfullname']
  @station_code     = hash['Stationcode']
  @query_time       = Time.parse(hash['Querytime'])
  @train_date       = hash['Traindate']
  @origin           = hash['Origin']
  @destination      = hash['Destination']
  @origin_time      = Time.parse hash['Origintime']
  @destination_time = Time.parse hash['Destinationtime']
  @status           = hash['Status']
  @last_location    = hash['Lastlocation']
  @duein            = hash['Duein']
  @late             = hash['Late']
  @exparrival       = Time.parse hash['Exparrival']
  @expdepart        = Time.parse hash['Expdepart']
  @scharrival       = Time.parse hash['Scharrival']
  @schdepart        = Time.parse hash['Schdepart']
  @direction        = hash['Direction']
  @train_type       = hash['Traintype']
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



2
3
4
# File 'lib/station_data.rb', line 2

def direction
  @direction
end

#dueinObject (readonly) Also known as: due_in

Returns the value of attribute duein.



2
3
4
# File 'lib/station_data.rb', line 2

def duein
  @duein
end

#expdepartObject (readonly)

Returns the value of attribute expdepart.



2
3
4
# File 'lib/station_data.rb', line 2

def expdepart
  @expdepart
end

#last_locationObject (readonly)

Returns the value of attribute last_location.



2
3
4
# File 'lib/station_data.rb', line 2

def last_location
  @last_location
end

#lateObject (readonly)

Returns the value of attribute late.



2
3
4
# File 'lib/station_data.rb', line 2

def late
  @late
end

#query_timeObject (readonly)

Returns the value of attribute query_time.



2
3
4
# File 'lib/station_data.rb', line 2

def query_time
  @query_time
end

#servertimeObject (readonly)

Returns the value of attribute servertime.



2
3
4
# File 'lib/station_data.rb', line 2

def servertime
  @servertime
end

#station_codeObject (readonly) Also known as: code

Returns the value of attribute station_code.



2
3
4
# File 'lib/station_data.rb', line 2

def station_code
  @station_code
end

#station_nameObject (readonly) Also known as: name

Returns the value of attribute station_name.



2
3
4
# File 'lib/station_data.rb', line 2

def station_name
  @station_name
end

#statusObject (readonly)

Returns the value of attribute status.



2
3
4
# File 'lib/station_data.rb', line 2

def status
  @status
end

#train_dateObject (readonly)

Returns the value of attribute train_date.



2
3
4
# File 'lib/station_data.rb', line 2

def train_date
  @train_date
end

#train_typeObject (readonly)

Returns the value of attribute train_type.



2
3
4
# File 'lib/station_data.rb', line 2

def train_type
  @train_type
end

#traincodeObject (readonly)

Returns the value of attribute traincode.



2
3
4
# File 'lib/station_data.rb', line 2

def traincode
  @traincode
end

Instance Method Details

#arrivalObject



37
38
39
# File 'lib/station_data.rb', line 37

def arrival
  {scheduled: @scharrival, expected: @exparrival}
end

#departureObject



41
42
43
# File 'lib/station_data.rb', line 41

def departure
  {scheduled: @schdepart, expected: @expdepart}
end

#destinationObject



33
34
35
# File 'lib/station_data.rb', line 33

def destination
  {name: @destination, time: @destination_time}
end

#late?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/station_data.rb', line 45

def late?
  @late.to_i > 0
end

#originObject



29
30
31
# File 'lib/station_data.rb', line 29

def origin
  {name: @origin, time: @origin_time}
end