Module: Ldp::Response::Paging
- Defined in:
- lib/ldp/response/paging.rb
Instance Method Summary collapse
-
#first_page ⇒ Object
Get the URI to the first page.
-
#has_next? ⇒ Boolean
Is there a next page?.
-
#next_page ⇒ Object
Get the URI for the next page.
-
#page ⇒ Object
Statements about the page.
- #sort ⇒ Object
-
#subject ⇒ Object
Get the subject for the response.
Instance Method Details
#first_page ⇒ Object
Get the URI to the first page
45 46 47 48 49 50 51 |
# File 'lib/ldp/response/paging.rb', line 45 def first_page if links['first'] RDF::URI.new links['first'] elsif graph.has_statement? RDf::Statement.new(page_subject, Ldp.nextPage, nil) subject end end |
#has_next? ⇒ Boolean
Is there a next page?
33 34 35 |
# File 'lib/ldp/response/paging.rb', line 33 def has_next? next_page != nil end |
#next_page ⇒ Object
Get the URI for the next page
39 40 41 |
# File 'lib/ldp/response/paging.rb', line 39 def next_page graph.first_object [page_subject, Ldp.nextPage, nil] end |
#page ⇒ Object
Statements about the page
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ldp/response/paging.rb', line 5 def page @page_graph ||= begin g = RDF::Graph.new if resource? res = graph.query RDF::Statement.new(page_subject, nil, nil) res.each_statement do |s| g << s end end g end end |
#sort ⇒ Object
53 54 55 |
# File 'lib/ldp/response/paging.rb', line 53 def sort end |
#subject ⇒ Object
Get the subject for the response
23 24 25 26 27 28 29 |
# File 'lib/ldp/response/paging.rb', line 23 def subject @subject ||= if has_page? graph.first_object [page_subject, Ldp.page_of, nil] else page_subject end end |