Class: Loggie::Logentries::Response
- Inherits:
-
Object
- Object
- Loggie::Logentries::Response
- Defined in:
- lib/loggie/logentries/response.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#leql ⇒ Object
readonly
Returns the value of attribute leql.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
Instance Method Summary collapse
- #events? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #next_url ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/loggie/logentries/response.rb', line 6 def initialize(response) data = JSON.parse response.read_body @logs = data["logs"] @links = data["links"] @leql = data["leql"] if data.key?("events") # 200 @events = data["events"] else # 202 for a query that successfully started but has not yet finished @progress = data["progress"] @id = data["id"] end end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
4 5 6 |
# File 'lib/loggie/logentries/response.rb', line 4 def events @events end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/loggie/logentries/response.rb', line 4 def id @id end |
#leql ⇒ Object (readonly)
Returns the value of attribute leql.
4 5 6 |
# File 'lib/loggie/logentries/response.rb', line 4 def leql @leql end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
4 5 6 |
# File 'lib/loggie/logentries/response.rb', line 4 def links @links end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
4 5 6 |
# File 'lib/loggie/logentries/response.rb', line 4 def logs @logs end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
4 5 6 |
# File 'lib/loggie/logentries/response.rb', line 4 def progress @progress end |
Instance Method Details
#events? ⇒ Boolean
26 27 28 |
# File 'lib/loggie/logentries/response.rb', line 26 def events? !@events.nil? end |
#next_url ⇒ Object
21 22 23 24 |
# File 'lib/loggie/logentries/response.rb', line 21 def next_url # res.fetch("links", [{}]).first.dig("href").gsub(/\?$/, '') links.first["href"] end |