Class: Redtube::Base

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

Direct Known Subclasses

Star, Tag, Video

Class Method Summary collapse

Class Method Details

.elements_by_query(query) ⇒ Object



7
8
9
# File 'lib/redtube/base.rb', line 7

def self.elements_by_query(query)
  Nokogiri::XML(get(query)).css name.downcase
end

.find_by_query(query) ⇒ Object



3
4
5
# File 'lib/redtube/base.rb', line 3

def self.find_by_query(query)
  elements_by_query(query).map { |element| new element }
end

.get(query) ⇒ Object



11
12
13
# File 'lib/redtube/base.rb', line 11

def self.get(query)
  open("http://api.redtube.com/?output=xml&data=redtube.#{name}s.#{query}").read
end

.nameObject



15
16
17
# File 'lib/redtube/base.rb', line 15

def self.name
  super.gsub("Redtube::", "")
end