Class: GovTrack::PaginatedList
- Defined in:
- lib/govtrack/paginated_list.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(object_class, meta, objects) ⇒ PaginatedList
constructor
A new instance of PaginatedList.
- #method_missing(method_id, *arguments) ⇒ Object
Constructor Details
#initialize(object_class, meta, objects) ⇒ PaginatedList
Returns a new instance of PaginatedList.
6 7 8 9 10 11 12 13 14 |
# File 'lib/govtrack/paginated_list.rb', line 6 def initialize(object_class,,objects) if @limit = ['limit'] @offset = ['offset'] @total = ['total_count'] end super((objects || []).map { |object| object_class.new(object) }) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *arguments) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/govtrack/paginated_list.rb', line 16 def method_missing(method_id, *arguments) #passes methods through to item when list contains only one if self.length == 1 self.first.send(method_id, *arguments) else super end end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
4 5 6 |
# File 'lib/govtrack/paginated_list.rb', line 4 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
4 5 6 |
# File 'lib/govtrack/paginated_list.rb', line 4 def offset @offset end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'lib/govtrack/paginated_list.rb', line 4 def total @total end |