Class: Revver4R::SearchBase

Inherits:
Object
  • Object
show all
Defined in:
lib/revver4r.rb

Direct Known Subclasses

VideoSearch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(media = "flash", feed_contents = "tag", criteria = "rails", options = {"affiliate" => "chalkers"}) ⇒ SearchBase

Returns a new instance of SearchBase.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/revver4r.rb', line 43

def initialize(media="flash", feed_contents="tag", criteria="rails", options = {"affiliate" => "chalkers"})
  if POSSIBLE_MEDIA_TYPES.include? media
    @media = media
  else
    raise "Invalid 'media' type. Choose from " + POSSIBLE_MEDIA_TYPES.join[", "]
  end

  if POSSIBLE_CONTENTS.include? feed_contents
    @feed_contents = feed_contents
  else
    raise "Invalid 'feed_content' type. Choose from " + POSSIBLE_CONTENTS.join[", "]
  end

  @criteria = criteria

  options.delete("affiliate") if options["affiliate"] == ""
  raise "Invalid 'offset' must be an Integer" if (options.has_key?"offset" && options["offset"].is_a?(Integer))
  raise "Invalid 'order'. Choose from "+ POSSIBLE_ORDERS.join[", "] if (options.has_key?"order" && !POSSIBLE_ORDERS.include?(options["order"]))
  raise "Invalid 'orderBy'. Choose from "+ POSSIBLE_ORDER_BYS.join[", "] if (options.has_key?"orderBy" && !POSSIBLE_ORDER_BYS.include?(options["order"]))

  ["minAgeRestriction","maxAgeRestriction"].each do |restriction|
     raise "Invalid '#{restriction}'. It must be between " + RESTRICTION_RANGE.first + " - " + RESTRICTION_RANGE.last if (options.has_key?restriction && !RESTRICTION_RANGE.include?(options[restriction]))
  end

  @options = options
end

Instance Attribute Details

#criteriaObject

Returns the value of attribute criteria.



42
43
44
# File 'lib/revver4r.rb', line 42

def criteria
  @criteria
end

#feed_contentsObject

Returns the value of attribute feed_contents.



42
43
44
# File 'lib/revver4r.rb', line 42

def feed_contents
  @feed_contents
end

#mediaObject

Returns the value of attribute media.



42
43
44
# File 'lib/revver4r.rb', line 42

def media
  @media
end

Instance Method Details

#searchObject



70
71
72
# File 'lib/revver4r.rb', line 70

def search
  raise "'search' method not implemented"
end