Class: Emites::Entities::Collection
- Extended by:
- Forwardable
- Defined in:
- lib/emites/entities/collection.rb
Constant Summary collapse
- PAGE_REGEX =
/page=(\d+)/
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(response, entity_class) ⇒ Collection
constructor
A new instance of Collection.
- #next_page ⇒ Object
- #previous_page ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(response, entity_class) ⇒ Collection
Returns a new instance of Collection.
12 13 14 15 16 17 |
# File 'lib/emites/entities/collection.rb', line 12 def initialize(response, entity_class) @response = response @entity_class = entity_class @total = parsed_body['count'].to_i @collection = [] end |
Instance Attribute Details
#total ⇒ Object (readonly)
Returns the value of attribute total.
9 10 11 |
# File 'lib/emites/entities/collection.rb', line 9 def total @total end |
Class Method Details
.build(response, entity_class) ⇒ Object
19 20 21 |
# File 'lib/emites/entities/collection.rb', line 19 def self.build(response, entity_class) self.new(response, entity_class).build end |
Instance Method Details
#build ⇒ Object
23 24 25 26 |
# File 'lib/emites/entities/collection.rb', line 23 def build build_collection self end |
#next_page ⇒ Object
28 29 30 |
# File 'lib/emites/entities/collection.rb', line 28 def next_page page_for('next') end |
#previous_page ⇒ Object
32 33 34 |
# File 'lib/emites/entities/collection.rb', line 32 def previous_page page_for('previous') end |
#to_a ⇒ Object
36 37 38 |
# File 'lib/emites/entities/collection.rb', line 36 def to_a @collection.clone end |