Class: CTA::CustomerAlerts::Alert
- Inherits:
-
Object
- Object
- CTA::CustomerAlerts::Alert
- Defined in:
- lib/cta_redux/api/customer_alerts.rb
Instance Attribute Summary collapse
-
#alert_id ⇒ Integer
readonly
The internal ID of this alert.
-
#category ⇒ Symbol
readonly
One of [:normal, :planned, :major, :minor].
-
#end ⇒ DateTime
readonly
The date and time at which this alert ends.
-
#full_description ⇒ String
readonly
A long-form summary for this alert.
-
#headline ⇒ String
readonly
A descriptive one-line summary for this alert.
-
#id ⇒ Integer
readonly
The internal ID of this alert.
-
#impact ⇒ String
readonly
Descriptive text detailing the impact of this alert.
-
#is_major_alert ⇒ true, 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.
-
#major_alert ⇒ true, 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.
-
#score ⇒ 0..99
readonly
A score that describes how an impact this alert will have on any affected services.
-
#services ⇒ Array<CTA::Route>
readonly
An array of Route objects that are impacted by this alert.
-
#severity_color ⇒ String
readonly
The hex color used to color text related to this alert on transitchicago.com.
-
#short_description ⇒ String
readonly
A descriptive short summary for this alert.
-
#start ⇒ DateTime
readonly
The date and time at which this alert takes effect.
-
#tbd ⇒ true, false
readonly
Returns true if the alert is ‘TBD’ - that is, the end time is unknown.
-
#url ⇒ String
readonly
A URL where customers could learn more about the alert.
Instance Method Summary collapse
-
#initialize(a) ⇒ Alert
constructor
A new instance of Alert.
-
#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.
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_id ⇒ Integer (readonly)
Returns 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 |
#category ⇒ Symbol (readonly)
Returns One of [:normal, :planned, :major, :minor].
46 47 48 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 46 def category @category end |
#end ⇒ DateTime (readonly)
Returns 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_description ⇒ String (readonly)
HTML formatted.
Returns 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 |
#headline ⇒ String (readonly)
Returns 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 |
#id ⇒ Integer (readonly)
Returns The internal ID of this alert.
30 31 32 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 30 def id @id end |
#impact ⇒ String (readonly)
Returns 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_alert ⇒ true, 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.
58 59 60 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 58 def is_major_alert @is_major_alert end |
#major_alert ⇒ true, 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.
56 57 58 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 56 def major_alert @major_alert end |
#score ⇒ 0..99 (readonly)
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.
42 43 44 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 42 def score @score end |
#services ⇒ Array<CTA::Route> (readonly)
Returns An array of Route objects that are impacted by this alert.
62 63 64 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 62 def services @services end |
#severity_color ⇒ String (readonly)
Returns 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_description ⇒ String (readonly)
Returns 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 |
#start ⇒ DateTime (readonly)
Returns 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 |
#tbd ⇒ true, false (readonly)
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 |
#url ⇒ String (readonly)
Returns 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.
85 86 87 |
# File 'lib/cta_redux/api/customer_alerts.rb', line 85 def major? @major_alert end |