Class: NerdLog::Encounter
- Inherits:
-
Object
- Object
- NerdLog::Encounter
- Defined in:
- lib/nerd_log/encounter.rb
Instance Attribute Summary collapse
-
#http_connection ⇒ Object
readonly
Returns the value of attribute http_connection.
Instance Method Summary collapse
- #encounters ⇒ Object
- #fetch ⇒ Object
-
#initialize(options = {}) ⇒ Encounter
constructor
A new instance of Encounter.
Constructor Details
#initialize(options = {}) ⇒ Encounter
Returns a new instance of Encounter.
6 7 8 |
# File 'lib/nerd_log/encounter.rb', line 6 def initialize( = {}) @http_connection = .fetch(:http_connection, NerdLog.configuration.http_connection) end |
Instance Attribute Details
#http_connection ⇒ Object (readonly)
Returns the value of attribute http_connection.
5 6 7 |
# File 'lib/nerd_log/encounter.rb', line 5 def http_connection @http_connection end |
Instance Method Details
#encounters ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nerd_log/encounter.rb', line 10 def encounters encounters = [] fetch.body.each do |zone| zone['encounters'].each do |encounter| encounters << OpenStruct.new(zone_id: zone['id'], id: encounter['id'], name: encounter['name']) end end encounters end |
#fetch ⇒ Object
23 24 25 26 27 |
# File 'lib/nerd_log/encounter.rb', line 23 def fetch response = http_connection.get("zones") response end |