Class: Embedit::Twitter

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Twitter



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

def initialize(url)
  @format = 'photo'
  @url = url
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Class Method Details

.match(url) ⇒ Object



25
26
27
# File 'lib/embedit/providers/twitter.rb', line 25

def self.match(url)
  url.match(/twitter\.com\/(\S+)\/statuses\/(\d+)/)
end

Instance Method Details

#html(options = {}) ⇒ Object



12
13
14
15
# File 'lib/embedit/providers/twitter.rb', line 12

def html(options = {})
  attributes = options.collect {|k,v| "#{k}=\"#{v}\" "}.join(" ")
  %{<img src="http://twictur.es/i/#{status_id}.gif" #{attributes} />}
end

#status_idObject



17
18
19
# File 'lib/embedit/providers/twitter.rb', line 17

def status_id
  @status_id ||= url[/twitter\.com\/(\S+)\/statuses\/(\d+)/,2]
end