Class: NgrokAPI::Models::Listable
- Inherits:
-
Object
- Object
- NgrokAPI::Models::Listable
- Includes:
- Enumerable
- Defined in:
- lib/ngrokapi/models/listable.rb
Overview
A resource representing multiple instances from a given “list” API call
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#iter ⇒ Object
readonly
Returns the value of attribute iter.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#list_property ⇒ Object
readonly
Returns the value of attribute list_property.
-
#next_page_uri ⇒ Object
readonly
Returns the value of attribute next_page_uri.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each ⇒ Object
-
#initialize(danger: false, client:, attrs:, list_property:, klass:) ⇒ Listable
constructor
A new instance of Listable.
- #to_s ⇒ Object
Constructor Details
#initialize(danger: false, client:, attrs:, list_property:, klass:) ⇒ Listable
Returns a new instance of Listable.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ngrokapi/models/listable.rb', line 21 def initialize(danger: false, client:, attrs:, list_property:, klass:) @client = client @attrs = attrs @list_property = list_property @next_page_uri = @attrs['next_page_uri'] @uri = @attrs['uri'] @items = @attrs[list_property].map do |item| klass.new(client: client, attrs: item) end @iter = NgrokAPI::PagedIterator.new( client: client, page: self, list_property: list_property, danger: danger ) end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def attrs @attrs end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def client @client end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def items @items end |
#iter ⇒ Object (readonly)
Returns the value of attribute iter.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def iter @iter end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def klass @klass end |
#list_property ⇒ Object (readonly)
Returns the value of attribute list_property.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def list_property @list_property end |
#next_page_uri ⇒ Object (readonly)
Returns the value of attribute next_page_uri.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def next_page_uri @next_page_uri end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
12 13 14 |
# File 'lib/ngrokapi/models/listable.rb', line 12 def uri @uri end |
Instance Method Details
#==(other) ⇒ Object
46 47 48 |
# File 'lib/ngrokapi/models/listable.rb', line 46 def ==(other) @attrs == other.attrs end |
#each ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/ngrokapi/models/listable.rb', line 38 def each item = @iter.get_next while item yield item item = @iter.get_next end end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/ngrokapi/models/listable.rb', line 50 def to_s @attrs.to_s end |