Sha256: e309d79f167f52af95f3539a6dcbe854a973bc3be4f53fc912f15e2de8417dab

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

module Ldp
  module Response::Paging  
    ##
    # Statements about the page
    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
    
    ##
    # Get the subject for the response
    def subject
      @subject ||= if has_page?
        graph.first_object [page_subject, Ldp.page_of, nil]
      else
        page_subject
      end
    end

    ##
    # Is there a next page?
    def has_next?
      next_page != nil
    end

    ##
    # Get the URI for the next page
    def next_page
      graph.first_object [page_subject, Ldp.nextPage, nil]
    end

    ##
    # Get the URI to the first page
    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

    def sort

    end
  end 
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ldp-0.4.1 lib/ldp/response/paging.rb
ldp-0.4.0 lib/ldp/response/paging.rb
ldp-0.3.1 lib/ldp/response/paging.rb
ldp-0.3.0 lib/ldp/response/paging.rb
ldp-0.2.3 lib/ldp/response/paging.rb
ldp-0.2.2 lib/ldp/response/paging.rb
ldp-0.2.1 lib/ldp/response/paging.rb
ldp-0.2.0 lib/ldp/response/paging.rb
ldp-0.1.0 lib/ldp/response/paging.rb
ldp-0.0.10 lib/ldp/response/paging.rb
ldp-0.0.9 lib/ldp/response/paging.rb
ldp-0.0.8 lib/ldp/response/paging.rb
ldp-0.0.7 lib/ldp/response/paging.rb
ldp-0.0.6 lib/ldp/response/paging.rb
ldp-0.0.5 lib/ldp/response/paging.rb
ldp-0.0.4 lib/ldp/response/paging.rb