Class: GoogleVideo::VideoSearchRequest

Inherits:
Record
  • Object
show all
Defined in:
lib/google-video.rb

Overview

Describes a search request for videos matching the specified parameters on Google Video. Parameters are specified via a hash passed to the object on construction mapping attribute names to their respective values.

Constant Summary collapse

SORT_OPTIONS =

the list of valid sort parameters.

[ 'relevance', 'rating', 'date', 'title' ]
DURATION_OPTIONS =

the list of valid duration parameters.

[ 'all', 'short', 'medium', 'long' ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ VideoSearchRequest

Constructs a VideoSearchRequest with the supplied hash mapping attribute names to their respective values.



357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/google-video.rb', line 357

def initialize (params)
  super(params)
  
  # validate request parameters
  if @sort && !SORT_OPTIONS.include?(@sort);
    raise ArgumentError.new("invalid sort parameter: #{@sort}")
  end
  if @duration && !DURATION_OPTIONS.include?(@duration)
    raise ArgumentError.new("invalid duration parameter: #{@duration}")
  end
  if !@query
    raise ArgumentError.new("invalid request, query parameter required")
  end
end

Instance Attribute Details

#durationObject (readonly)

optional: the duration by which to filter search results: one of ‘all’, ‘short’, ‘medium’ or ‘long’, defaulting to ‘all’.



343
344
345
# File 'lib/google-video.rb', line 343

def duration
  @duration
end

#pageObject (readonly)

optional: the page number of results sought, defaulting to 1.



349
350
351
# File 'lib/google-video.rb', line 349

def page
  @page
end

#queryObject (readonly)

required: the query string by which to search.



346
347
348
# File 'lib/google-video.rb', line 346

def query
  @query
end

#results_per_pageObject (readonly)

optional: the number of results to display per page, defaulting to 10 and at most 100.



353
354
355
# File 'lib/google-video.rb', line 353

def results_per_page
  @results_per_page
end

#sortObject (readonly)

optional: the sort order for search results: one of ‘relevance’, ‘rating’, ‘date’, ‘title’, defaulting to ‘relevance’.



339
340
341
# File 'lib/google-video.rb', line 339

def sort
  @sort
end