Class: Embedit::Media

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Media

delegate :title, :html, :format, :to => :provider



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/embedit/media.rb', line 10

def initialize(url)
  @valid    = true
  @url      = url
  @provider = Provider.find(url)
  # The validation does a expensive GET request. needs to be fixed. (request only the headers?!) 
  if !@provider || !Validate.new(@url).valid?
    @valid = false
    return
  end 

rescue #Horrible hack, but flickrs poor status headers == :( 
  @valid = false #if it breaks, its gotta be invalid, I suggest removing when debugging                                                 
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



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

def format
  @format
end

#html(args = {}) ⇒ Object

Returns the value of attribute html.



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

def html
  @html
end

#providerObject

Returns the value of attribute provider.



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

def provider
  @provider
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#valid?Boolean



37
38
39
# File 'lib/embedit/media.rb', line 37

def valid?
  @valid    
end