Class: Umatic::Channel

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

Direct Known Subclasses

Vimeo, Youtube

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Channel

Returns a new instance of Channel.



27
28
29
# File 'lib/channel/channel.rb', line 27

def initialize(url)
  @url = url
end

Class Method Details

.channelsObject



9
# File 'lib/channel/channel.rb', line 9

def self.channels; @@channels; end

.inherited(subclass) ⇒ Object



11
12
13
14
# File 'lib/channel/channel.rb', line 11

def self.inherited(subclass)
  @@channels ||= []
  @@channels << subclass
end

.open(url) ⇒ Object



16
17
18
19
20
21
# File 'lib/channel/channel.rb', line 16

def self.open(url)
  @@channels.each do |c|
    return c.new(url) if c.supports? url
  end
  nil
end

.supports?(url) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/channel/channel.rb', line 23

def self.supports? url
  false
end

Instance Method Details

#parse(page) ⇒ Object



31
32
33
# File 'lib/channel/channel.rb', line 31

def parse(page)
  raise "Parsing not implemented for #{self.class}"
end

#processObject



35
36
37
38
# File 'lib/channel/channel.rb', line 35

def process
  page = HTTPClient.instance.get @url
  parse page
end