Class: YouTubeIt::Response::VideoSearch

Inherits:
YouTubeIt::Record show all
Defined in:
lib/youtube_it/response/video_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from YouTubeIt::Record

#initialize

Constructor Details

This class inherits a constructor from YouTubeIt::Record

Instance Attribute Details

#feed_idObject (readonly)

String

Unique feed identifying url.



5
6
7
# File 'lib/youtube_it/response/video_search.rb', line 5

def feed_id
  @feed_id
end

#max_result_countObject (readonly)

Fixnum

Number of results per page.



8
9
10
# File 'lib/youtube_it/response/video_search.rb', line 8

def max_result_count
  @max_result_count
end

#offsetObject (readonly)

Fixnum

1-based offset index into the full result set.



11
12
13
# File 'lib/youtube_it/response/video_search.rb', line 11

def offset
  @offset
end

#total_result_countObject (readonly)

Fixnum

Total number of results available for the original request.



14
15
16
# File 'lib/youtube_it/response/video_search.rb', line 14

def total_result_count
  @total_result_count
end

#updated_atObject (readonly)

Time

Date and time at which the feed was last updated



17
18
19
# File 'lib/youtube_it/response/video_search.rb', line 17

def updated_at
  @updated_at
end

#videosObject (readonly)

Array

Array of YouTubeIt::Model::Video records



20
21
22
# File 'lib/youtube_it/response/video_search.rb', line 20

def videos
  @videos
end

Instance Method Details

#current_pageObject



22
23
24
# File 'lib/youtube_it/response/video_search.rb', line 22

def current_page
  ((offset - 1) / max_result_count) + 1
end

#next_pageObject

current_page + 1 or nil if there is no next page



27
28
29
# File 'lib/youtube_it/response/video_search.rb', line 27

def next_page
  current_page < total_pages ? (current_page + 1) : nil
end

#previous_pageObject

current_page - 1 or nil if there is no previous page



32
33
34
# File 'lib/youtube_it/response/video_search.rb', line 32

def previous_page
  current_page > 1 ? (current_page - 1) : nil
end

#total_pagesObject



36
37
38
# File 'lib/youtube_it/response/video_search.rb', line 36

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