Class: Waffle::Maker::Api::Alert
- Defined in:
- lib/waffle/maker/api/alert.rb
Constant Summary collapse
- API_PATH =
'/api/v1/alert'
Constants inherited from Base
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#marker ⇒ Object
readonly
Returns the value of attribute marker.
-
#time_order ⇒ Object
readonly
Returns the value of attribute time_order.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes inherited from Base
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(time_order: nil, from: nil, to: nil, ip: nil, marker: nil) ⇒ Alert
constructor
A new instance of Alert.
- #matched_with_routes ⇒ Object
- #url ⇒ Object
Methods inherited from Base
#body_in_hash_format, #body_in_json_format, #get, #http
Constructor Details
#initialize(time_order: nil, from: nil, to: nil, ip: nil, marker: nil) ⇒ Alert
Returns a new instance of Alert.
10 11 12 13 14 15 16 |
# File 'lib/waffle/maker/api/alert.rb', line 10 def initialize(time_order: nil, from: nil, to: nil, ip: nil, marker: nil) @time_order = time_order @from = from @to = to @ip = ip @marker = marker end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
8 9 10 |
# File 'lib/waffle/maker/api/alert.rb', line 8 def from @from end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
8 9 10 |
# File 'lib/waffle/maker/api/alert.rb', line 8 def ip @ip end |
#marker ⇒ Object (readonly)
Returns the value of attribute marker.
8 9 10 |
# File 'lib/waffle/maker/api/alert.rb', line 8 def marker @marker end |
#time_order ⇒ Object (readonly)
Returns the value of attribute time_order.
8 9 10 |
# File 'lib/waffle/maker/api/alert.rb', line 8 def time_order @time_order end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
8 9 10 |
# File 'lib/waffle/maker/api/alert.rb', line 8 def to @to end |
Instance Method Details
#execute ⇒ Object
18 19 20 |
# File 'lib/waffle/maker/api/alert.rb', line 18 def execute body_in_hash_format end |
#matched_with_routes ⇒ Object
22 23 24 25 26 |
# File 'lib/waffle/maker/api/alert.rb', line 22 def matched_with_routes body_in_hash_format.tap do |body| body['data'].select! { |d| Waffle::Maker::Matcher.new(d['uri'], routes).matched? } end end |
#url ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/waffle/maker/api/alert.rb', line 28 def url return @url if @url url_string = "#{config.api_host}#{API_PATH}?host=#{config.host}&id=#{config.id}" url_string = "#{url_string}&time_order=#{@time_order}" if @time_order url_string = "#{url_string}&from=#{@from}" if @from url_string = "#{url_string}&to=#{@to}" if @to url_string = "#{url_string}&ip=#{@ip}" if @ip url_string = "#{url_string}&marker=#{@marker}" if @marker @url = URI.parse(url_string) end |