Class: Embedit::Ovi

Inherits:
Object
  • Object
show all
Defined in:
lib/embedit/providers/ovi.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Ovi

Returns a new instance of Ovi.



8
9
10
# File 'lib/embedit/providers/ovi.rb', line 8

def initialize(url)
  @url = url
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



6
7
8
# File 'lib/embedit/providers/ovi.rb', line 6

def format
  @format
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/embedit/providers/ovi.rb', line 6

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/embedit/providers/ovi.rb', line 6

def url
  @url
end

Class Method Details

.match(url) ⇒ Object



31
32
33
# File 'lib/embedit/providers/ovi.rb', line 31

def self.match(url)
  url.match(/share\.ovi\.com/)
end

Instance Method Details

#html(size = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/embedit/providers/ovi.rb', line 12

def html(size = {})
  @html = original_html
  @html.gsub!(/height="\d+"/, %{height="#{size[:height]}"}) if size[:height]
  @html.gsub!(/width="\d+"/, %{width="#{size[:width]}"}) if size[:width]
  @html
end

#original_htmlObject



39
40
41
42
43
44
45
46
# File 'lib/embedit/providers/ovi.rb', line 39

def original_html
  return @original_html if @original_html
  @original_html = page.search("tr#M_sidebar_uimediaembed_uifp1 td input").first.attributes['value'] rescue nil  #We first search for video or audio, if not its got to be image (hopfully)
  if @original_html.nil?
    @original_html = page.search("div#M_sidebar_uimediaembed_uiip td input#M_sidebar_uimediaembed_uihtml2").first.attributes['value'].gsub(/<a \S+>/, '').gsub(/<\/a>/, '')  #Follow Embedit convention, images should not be surrounded a a <a href></a>
  end
  @original_html
end

#pageObject



35
36
37
# File 'lib/embedit/providers/ovi.rb', line 35

def page
  @page ||= Hpricot(open(@url))
end