Class: AMEE::Limiter
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
load_xml_doc, node_value, xmlpathpreamble
Constructor Details
#initialize(data) ⇒ Limiter
80
81
82
83
84
|
# File 'lib/amee/pager.rb', line 80
def initialize(data)
@offset=data[:resultStart] || 0
@limit=data[:resultLimit] || 10
@truncated=data[:truncated] || false
end
|
Instance Attribute Details
Returns the value of attribute limit.
85
86
87
|
# File 'lib/amee/pager.rb', line 85
def limit
@limit
end
|
Returns the value of attribute offset.
85
86
87
|
# File 'lib/amee/pager.rb', line 85
def offset
@offset
end
|
#truncated ⇒ Object
Returns the value of attribute truncated.
85
86
87
|
# File 'lib/amee/pager.rb', line 85
def truncated
@truncated
end
|
Class Method Details
.from_json(doc, options = {}) ⇒ Object
99
100
101
|
# File 'lib/amee/pager.rb', line 99
def self.from_json(doc,options={})
raise AMEE::NotSupported
end
|
.from_xml(node, options = {}) ⇒ Object
102
103
104
105
106
|
# File 'lib/amee/pager.rb', line 102
def self.from_xml(node,options={})
t=x('@truncated',:doc=>node)
options[:truncated] = (t=='true') if t
Limiter.new options
end
|
Instance Method Details
#more? ⇒ Boolean
86
87
88
|
# File 'lib/amee/pager.rb', line 86
def more?
truncated
end
|
89
90
91
92
|
# File 'lib/amee/pager.rb', line 89
def next!
@offset+=limit
more?
end
|
96
97
98
|
# File 'lib/amee/pager.rb', line 96
def options
{:resultStart=>offset,:resultLimit=>limit}
end
|
#page_fragment ⇒ Object
93
94
95
|
# File 'lib/amee/pager.rb', line 93
def page_fragment
"?resultStart=#{offset}&resultLimit=#{limit}"
end
|