Class: Sirportly::DataSet
- Inherits:
-
Array
- Object
- Array
- Sirportly::DataSet
- Defined in:
- lib/sirportly/data_set.rb
Instance Method Summary collapse
-
#initialize(client, records, klass) ⇒ DataSet
constructor
A new instance of DataSet.
- #offset ⇒ Object
- #page ⇒ Object
- #pages ⇒ Object
- #per_page ⇒ Object
- #total_records ⇒ Object
Constructor Details
#initialize(client, records, klass) ⇒ DataSet
Returns a new instance of DataSet.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/sirportly/data_set.rb', line 4 def initialize(client, records, klass) @pagination = {} if records.is_a?(Hash) @pagination = records['pagination'] records = records['records'] end records.map! { |r| klass.new(client, r) } self.push(*records) end |
Instance Method Details
#offset ⇒ Object
31 32 33 |
# File 'lib/sirportly/data_set.rb', line 31 def offset @pagination['offset'] end |
#page ⇒ Object
15 16 17 |
# File 'lib/sirportly/data_set.rb', line 15 def page @pagination['page'] end |
#pages ⇒ Object
27 28 29 |
# File 'lib/sirportly/data_set.rb', line 27 def pages @pagination['pages'] end |
#per_page ⇒ Object
23 24 25 |
# File 'lib/sirportly/data_set.rb', line 23 def per_page @pagination['per_page'] end |
#total_records ⇒ Object
19 20 21 |
# File 'lib/sirportly/data_set.rb', line 19 def total_records @pagination['total_records'] end |