Class: Embedit::Image

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Image



7
8
9
# File 'lib/embedit/providers/image.rb', line 7

def initialize(url)
  @url = url
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



5
6
7
# File 'lib/embedit/providers/image.rb', line 5

def format
  @format
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/embedit/providers/image.rb', line 5

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/embedit/providers/image.rb', line 5

def url
  @url
end

Class Method Details

.match(url) ⇒ Object



18
19
20
# File 'lib/embedit/providers/image.rb', line 18

def self.match(url)
  url.match(/(.+\.(gif|jpg|png)$)/)
end

Instance Method Details

#html(options = {}) ⇒ Object



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

def html(options = {})
  attributes = options.collect {|k,v| "#{k}=\"#{v}\" "}.join(" ")
  %{
    <a href="#{@url}"><img src="#{@url}" #{attributes}/></a>
  } 
end