Class: MassHighways::Event

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def direction
  @direction
end

#event_categoryObject

Returns the value of attribute event_category.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_category
  @event_category
end

#event_created_dateObject

Returns the value of attribute event_created_date.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_created_date
  @event_created_date
end

#event_end_dateObject

Returns the value of attribute event_end_date.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_end_date
  @event_end_date
end

#event_idObject

Returns the value of attribute event_id.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_id
  @event_id
end

#event_start_dateObject

Returns the value of attribute event_start_date.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_start_date
  @event_start_date
end

#event_statusObject

Returns the value of attribute event_status.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_status
  @event_status
end

#event_sub_typeObject

Returns the value of attribute event_sub_type.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_sub_type
  @event_sub_type
end

#event_typeObject

Returns the value of attribute event_type.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def event_type
  @event_type
end

#lane_blockage_descriptionObject

Returns the value of attribute lane_blockage_description.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def lane_blockage_description
  @lane_blockage_description
end

#last_updateObject

Returns the value of attribute last_update.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def last_update
  @last_update
end

#location_descriptionObject

Returns the value of attribute location_description.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def location_description
  @location_description
end

#location_typeObject

Returns the value of attribute location_type.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def location_type
  @location_type
end

#primary_latitudeObject

Returns the value of attribute primary_latitude.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def primary_latitude
  @primary_latitude
end

#primary_longitudeObject

Returns the value of attribute primary_longitude.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def primary_longitude
  @primary_longitude
end

#recurrence_descriptionObject

Returns the value of attribute recurrence_description.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def recurrence_description
  @recurrence_description
end

#roadway_nameObject

Returns the value of attribute roadway_name.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def roadway_name
  @roadway_name
end

#secondary_latitudeObject

Returns the value of attribute secondary_latitude.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def secondary_latitude
  @secondary_latitude
end

#secondary_longitudeObject

Returns the value of attribute secondary_longitude.



3
4
5
# File 'lib/mass_highways/event.rb', line 3

def secondary_longitude
  @secondary_longitude
end

Class Method Details

.parse(node) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mass_highways/event.rb', line 9

def self.parse(node)
  event = self.new
  event.event_id = node.search('EventId').first.text.to_i
  event.event_created_date = DateTime.parse node.search('EventCreatedDate').first.text
  event.event_start_date = DateTime.parse node.search('EventStartDate').first.text

  end_date = node.search('EventEndDate').first.text
  event.event_end_date = DateTime.parse end_date unless end_date.empty?

  event.last_update = DateTime.parse node.search('LastUpdate').first.text
  event.event_status = node.search('EventStatus').first.text
  event.event_category = node.search('EventCategory').first.text
  event.event_type = node.search('EventType').first.text
  event.event_sub_type = node.search('EventSubType').first.text

  event.roadway_name              = node.search('RoadwayName').first.text
  event.direction                 = node.search('Direction').first.text
  event.location_type             = node.search('LocationType').first.text
  event.primary_latitude          = node.search('PrimaryLatitude').first.text.to_f
  event.primary_longitude         = node.search('PrimaryLongitude').first.text.to_f

  secondary_latitude = node.search('SecondaryLatitude').first.text
  event.secondary_latitude        = secondary_latitude.to_i unless secondary_latitude == 'NaN'

  secondary_longitude = node.search('SecondaryLongitude').first.text
  event.secondary_longitude       = secondary_longitude.to_i unless secondary_longitude == 'NaN'

  event.location_description      = node.search('LocationDescription').first.text
  event.lane_blockage_description = node.search('LaneBlockageDescription').first.text
  event.recurrence_description    = node.search('RecurrenceDescription').first.text

  event
end