Class: AMEE::Limiter
- Inherits:
-
Object
- Object
- AMEE::Limiter
- Extended by:
- ParseHelper
- Defined in:
- lib/amee/pager.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#truncated ⇒ Object
readonly
Returns the value of attribute truncated.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Limiter
constructor
A new instance of Limiter.
- #more? ⇒ Boolean
- #next! ⇒ Object
- #options ⇒ Object
- #page_fragment ⇒ Object
Methods included from ParseHelper
Constructor Details
#initialize(data) ⇒ Limiter
Returns a new instance of Limiter.
76 77 78 79 80 |
# File 'lib/amee/pager.rb', line 76 def initialize(data) @offset=data[:resultStart] || 0 @limit=data[:resultLimit] || 10 @truncated=data[:truncated] || false end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
81 82 83 |
# File 'lib/amee/pager.rb', line 81 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
81 82 83 |
# File 'lib/amee/pager.rb', line 81 def offset @offset end |
#truncated ⇒ Object (readonly)
Returns the value of attribute truncated.
81 82 83 |
# File 'lib/amee/pager.rb', line 81 def truncated @truncated end |
Class Method Details
.from_json(doc, options = {}) ⇒ Object
95 96 97 |
# File 'lib/amee/pager.rb', line 95 def self.from_json(doc,={}) raise AMEE::NotSupported end |
Instance Method Details
#more? ⇒ Boolean
82 83 84 |
# File 'lib/amee/pager.rb', line 82 def more? truncated end |
#next! ⇒ Object
85 86 87 88 |
# File 'lib/amee/pager.rb', line 85 def next! @offset+=limit more? end |
#options ⇒ Object
92 93 94 |
# File 'lib/amee/pager.rb', line 92 def {:resultStart=>offset,:resultLimit=>limit} end |
#page_fragment ⇒ Object
89 90 91 |
# File 'lib/amee/pager.rb', line 89 def page_fragment "?resultStart=#{offset}&resultLimit=#{limit}" end |