Class: CTA::CustomerAlerts::Alert

Inherits:
Object
  • Object
show all
Defined in:
lib/cta_redux/api/customer_alerts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a) ⇒ Alert

Returns a new instance of Alert.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cta_redux/api/customer_alerts.rb', line 64

def initialize(a)
  @id = @alert_id = a["AlertId"].to_i
  @headline = a["Headline"]
  @short_description = a["ShortDescription"]
  @full_description = a["FullDescription"]
  @score = a["SeverityScore"].to_i
  @severity_color = a["SeverityColor"]
  @category = a["SeverityCSS"].downcase.to_sym
  @impact = a["Impact"]
  @start = DateTime.parse(a["EventStart"]) if a["EventStart"]
  @end = DateTime.parse(a["EventEnd"]) if a["EventEnd"]
  @tbd = (a["TBD"] == "1")
  @major_alert = @is_major_alert = (a["MajorAlert"] == "1")
  @url = a["AlertURL"]

  @services = Array.wrap(a["ImpactedService"]["Service"]).map do |s|
    CTA::Route.where(:route_id => s["ServiceName"].split(" ")).or(:route_id => s["ServiceId"]).first
  end
end

Instance Attribute Details

#alert_idInteger (readonly)

Returns The internal ID of this alert.

Returns:

  • (Integer)

    The internal ID of this alert



32
33
34
# File 'lib/cta_redux/api/customer_alerts.rb', line 32

def alert_id
  @alert_id
end

#categorySymbol (readonly)

Returns One of [:normal, :planned, :major, :minor].

Returns:

  • (Symbol)

    One of [:normal, :planned, :major, :minor]



46
47
48
# File 'lib/cta_redux/api/customer_alerts.rb', line 46

def category
  @category
end

#endDateTime (readonly)

Returns The date and time at which this alert ends. May be unknown.

Returns:

  • (DateTime)

    The date and time at which this alert ends. May be unknown.



52
53
54
# File 'lib/cta_redux/api/customer_alerts.rb', line 52

def end
  @end
end

#full_descriptionString (readonly)

Note:

HTML formatted.

Returns A long-form summary for this alert.

Returns:

  • (String)

    A long-form summary for this alert.



39
40
41
# File 'lib/cta_redux/api/customer_alerts.rb', line 39

def full_description
  @full_description
end

#headlineString (readonly)

Returns A descriptive one-line summary for this alert.

Returns:

  • (String)

    A descriptive one-line summary for this alert



34
35
36
# File 'lib/cta_redux/api/customer_alerts.rb', line 34

def headline
  @headline
end

#idInteger (readonly)

Returns The internal ID of this alert.

Returns:

  • (Integer)

    The internal ID of this alert



30
31
32
# File 'lib/cta_redux/api/customer_alerts.rb', line 30

def id
  @id
end

#impactString (readonly)

Returns Descriptive text detailing the impact of this alert.

Returns:

  • (String)

    Descriptive text detailing the impact of this alert.



48
49
50
# File 'lib/cta_redux/api/customer_alerts.rb', line 48

def impact
  @impact
end

#is_major_alerttrue, false (readonly)

Returns true if the alert is ‘major’ - that is the CTA is displaying it prominently on transitchicago.com and expects it to cause major headaches.

Returns:

  • (true, false)

    Returns true if the alert is ‘major’ - that is the CTA is displaying it prominently on transitchicago.com and expects it to cause major headaches.



58
59
60
# File 'lib/cta_redux/api/customer_alerts.rb', line 58

def is_major_alert
  @is_major_alert
end

#major_alerttrue, false (readonly)

Returns true if the alert is ‘major’ - that is the CTA is displaying it prominently on transitchicago.com and expects it to cause major headaches.

Returns:

  • (true, false)

    Returns true if the alert is ‘major’ - that is the CTA is displaying it prominently on transitchicago.com and expects it to cause major headaches.



56
57
58
# File 'lib/cta_redux/api/customer_alerts.rb', line 56

def major_alert
  @major_alert
end

#score0..99 (readonly)

Note:

The score ranges from 0-99. It’s unclear how this is calculated internally, but higher numbers seem to be worse.

Returns A score that describes how an impact this alert will have on any affected services.

Returns:

  • (0..99)

    A score that describes how an impact this alert will have on any affected services.



42
43
44
# File 'lib/cta_redux/api/customer_alerts.rb', line 42

def score
  @score
end

#servicesArray<CTA::Route> (readonly)

Returns An array of Route objects that are impacted by this alert.

Returns:



62
63
64
# File 'lib/cta_redux/api/customer_alerts.rb', line 62

def services
  @services
end

#severity_colorString (readonly)

Returns The hex color used to color text related to this alert on transitchicago.com.

Returns:

  • (String)

    The hex color used to color text related to this alert on transitchicago.com



44
45
46
# File 'lib/cta_redux/api/customer_alerts.rb', line 44

def severity_color
  @severity_color
end

#short_descriptionString (readonly)

Returns A descriptive short summary for this alert.

Returns:

  • (String)

    A descriptive short summary for this alert



36
37
38
# File 'lib/cta_redux/api/customer_alerts.rb', line 36

def short_description
  @short_description
end

#startDateTime (readonly)

Returns The date and time at which this alert takes effect.

Returns:

  • (DateTime)

    The date and time at which this alert takes effect.



50
51
52
# File 'lib/cta_redux/api/customer_alerts.rb', line 50

def start
  @start
end

#tbdtrue, false (readonly)

Returns true if the alert is ‘TBD’ - that is, the end time is unknown.

Returns:

  • (true, false)

    Returns true if the alert is ‘TBD’ - that is, the end time is unknown.



54
55
56
# File 'lib/cta_redux/api/customer_alerts.rb', line 54

def tbd
  @tbd
end

#urlString (readonly)

Returns A URL where customers could learn more about the alert.

Returns:

  • (String)

    A URL where customers could learn more about the alert.



60
61
62
# File 'lib/cta_redux/api/customer_alerts.rb', line 60

def url
  @url
end

Instance Method Details

#major?true, false

Returns true if the alert is ‘major’ - that is the CTA is displaying it prominently on transitchicago.com and expects it to cause major headaches.

Returns:

  • (true, false)

    Returns true if the alert is ‘major’ - that is the CTA is displaying it prominently on transitchicago.com and expects it to cause major headaches.



85
86
87
# File 'lib/cta_redux/api/customer_alerts.rb', line 85

def major?
  @major_alert
end