Sha256: 450581bf5efa0e7e47bc4246084fff9bb11771423d9ca946e5f5a1a7cb4e5c48

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

class YouTubeG
  module Response
    class VideoSearch < YouTubeG::Record
      # *String*:: Unique feed identifying url.
      attr_reader :feed_id 
      
      # *Fixnum*:: Number of results per page.
      attr_reader :max_result_count
      
      # *Fixnum*:: 1-based offset index into the full result set.
      attr_reader :offset
      
      # *Fixnum*:: Total number of results available for the original request.
      attr_reader :total_result_count

      # *Time*:: Date and time at which the feed was last updated
      attr_reader :updated_at

      # *Array*:: Array of YouTubeG::Model::Video records
      attr_reader :videos

      def current_page
        ((offset - 1) / max_result_count) + 1
      end
      
      # current_page + 1 or nil if there is no next page
      def next_page
        current_page < total_pages ? (current_page + 1) : nil
      end

      # current_page - 1 or nil if there is no previous page
      def previous_page
        current_page > 1 ? (current_page - 1) : nil
      end

      def total_pages
        (total_result_count / max_result_count.to_f).ceil
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 8 rubygems

Version Path
youtube-g-es-0.5.1 lib/youtube_g/response/video_search.rb
beef-youtube-g-0.4.9.9 lib/youtube_g/response/video_search.rb
pius-youtube-g-0.5.1 lib/youtube_g/response/video_search.rb
tmm1-youtube-g-0.5.0 lib/youtube_g/response/video_search.rb
tmm1-youtube-g-0.5.1 lib/youtube_g/response/video_search.rb
agiley-youtube-g-0.6.3 lib/youtube_g/response/video_search.rb
agiley-youtube-g-0.6.2 lib/youtube_g/response/video_search.rb
natedaiger-youtube-g-0.6.1 lib/youtube_g/response/video_search.rb
natedaiger-youtube-g-0.6.0 lib/youtube_g/response/video_search.rb
natedaiger-youtube-g-0.5.1 lib/youtube_g/response/video_search.rb
mintdigital-youtube-g-0.5.1 lib/youtube_g/response/video_search.rb
youtube-g-0.5.0 lib/youtube_g/response/video_search.rb
youtube-g-0.4.9.9 lib/youtube_g/response/video_search.rb