Class: CleverSDK::Data::Districts
- Inherits:
-
Object
- Object
- CleverSDK::Data::Districts
- Includes:
- Enumerable
- Defined in:
- lib/clever_sdk/data/districts.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
private.
Instance Method Summary collapse
- #data ⇒ Object
- #each(&block) ⇒ Object (also: #all)
-
#initialize(response) ⇒ Districts
constructor
private.
- #inspect ⇒ Object
Constructor Details
#initialize(response) ⇒ Districts
private
14 15 16 |
# File 'lib/clever_sdk/data/districts.rb', line 14 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
private
11 12 13 |
# File 'lib/clever_sdk/data/districts.rb', line 11 def response @response end |
Instance Method Details
#data ⇒ Object
18 19 20 |
# File 'lib/clever_sdk/data/districts.rb', line 18 def data @data ||= Array(response.body.dig("data")) end |
#each(&block) ⇒ Object Also known as: all
22 23 24 25 26 27 28 29 |
# File 'lib/clever_sdk/data/districts.rb', line 22 def each &block return enum_for :each unless block data .lazy .map { |datum| CleverSDK::Data::District.new(datum.dig("data"), response) } .each(&block) end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/clever_sdk/data/districts.rb', line 32 def inspect "#<#{self.class.name}:0x#{(object_id * 2).to_s(16).rjust(16, "0")} districts:#{data.count}>" end |