Class: CMIS::Query
- Inherits:
-
Object
- Object
- CMIS::Query
- Defined in:
- lib/cmis/query.rb
Instance Method Summary collapse
-
#each_page(options = {}, &block) ⇒ Object
Options: limit.
-
#each_result(options = {}, &block) ⇒ Object
Options: limit.
- #has_next? ⇒ Boolean
-
#initialize(repository, statement, options = {}) ⇒ Query
constructor
Options: from, page_size.
- #results ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(repository, statement, options = {}) ⇒ Query
Options: from, page_size
4 5 6 7 8 9 10 |
# File 'lib/cmis/query.rb', line 4 def initialize(repository, statement, = {}) @repository = repository @statement = statement @options = .stringify_keys end |
Instance Method Details
#each_page(options = {}, &block) ⇒ Object
Options: limit
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cmis/query.rb', line 30 def each_page( = {}, &block) return enum_for(:each_page, ) unless block_given? limit = parse_limit() counter = 0 while has_next? break unless counter < limit yield r = results counter += r.size end end |
#each_result(options = {}, &block) ⇒ Object
Options: limit
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cmis/query.rb', line 13 def each_result( = {}, &block) return enum_for(:each_result, ) unless block_given? limit = parse_limit() counter = 0 while has_next? results.each do |object| break unless counter < limit yield object counter = counter.next end end end |
#has_next? ⇒ Boolean
54 55 56 |
# File 'lib/cmis/query.rb', line 54 def has_next? @has_next end |
#results ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/cmis/query.rb', line 44 def results result = do_query @skip_count += result.results.size @has_next = result.has_more_items @total = result.num_items result.results end |
#total ⇒ Object
58 59 60 |
# File 'lib/cmis/query.rb', line 58 def total @total ||= do_query.num_items end |