Class: PagerDuty::Alert

Inherits:
Report::Item show all
Defined in:
lib/pagerduty_tools/pagerduty.rb

Instance Attribute Summary collapse

Attributes inherited from Report::Item

#time

Instance Method Summary collapse

Methods inherited from Report::Item

#between?, #graveyard?, #off_hours?

Constructor Details

#initialize(time, type, user) ⇒ Alert

Returns a new instance of Alert.



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/pagerduty_tools/pagerduty.rb', line 181

def initialize(time, type, user)
  # This charming little chunk works around an apparent bug in Chronic:
  # if the parsed month is the same as the current month, :context =>
  # :past will fail to set the month correctly.  (Looks like
  # 'if @now.month > target_month' on line 28 of
  # chronic-0.3.0/lib/chronic/repeaters/repeater_month_name.rb
  # should be 'if @now.month >= target_month'.) Anyway, there, I
  # fixed it.
  if time.start_with?(Time.now.strftime("%b"))
    super(Chronic.parse(time))
  else
    super(Chronic.parse(time, :context => :past))
  end
  @type = type
  @user = user
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



179
180
181
# File 'lib/pagerduty_tools/pagerduty.rb', line 179

def type
  @type
end

#userObject

Returns the value of attribute user.



179
180
181
# File 'lib/pagerduty_tools/pagerduty.rb', line 179

def user
  @user
end

Instance Method Details

#email?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/pagerduty_tools/pagerduty.rb', line 202

def email?
  type == "Email"
end

#phone_or_sms?Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/pagerduty_tools/pagerduty.rb', line 198

def phone_or_sms?
  type == "Phone" or type == "SMS"
end