Module: Extractula::OEmbed::InstanceMethods

Defined in:
lib/extractula/oembed.rb

Instance Method Summary collapse

Instance Method Details

#image_urlsObject



104
105
106
# File 'lib/extractula/oembed.rb', line 104

def image_urls
  [ oembed.url ] if oembed && oembed.type == 'photo'
end

#initialize(*args) ⇒ Object



63
64
65
66
# File 'lib/extractula/oembed.rb', line 63

def initialize(*args)
  super
  @oembed = Extractula::OEmbed.request(oembed_request)
end

#oembedObject



84
85
86
# File 'lib/extractula/oembed.rb', line 84

def oembed
  @oembed
end

#oembed_endpointObject



68
69
70
# File 'lib/extractula/oembed.rb', line 68

def oembed_endpoint
  self.class.oembed_endpoint
end

#oembed_format_param_required?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/extractula/oembed.rb', line 80

def oembed_format_param_required?
  self.class.oembed_format_param_required?
end

#oembed_max_heightObject



76
77
78
# File 'lib/extractula/oembed.rb', line 76

def oembed_max_height
  self.class.oembed_max_height
end

#oembed_max_widthObject



72
73
74
# File 'lib/extractula/oembed.rb', line 72

def oembed_max_width
  self.class.oembed_max_width
end

#oembed_requestObject



88
89
90
91
92
93
94
# File 'lib/extractula/oembed.rb', line 88

def oembed_request
  request = "#{oembed_endpoint}?url=#{oembed_request_url}"
  request += "&format=json" if oembed_format_param_required?
  request += "&maxwidth=#{oembed_max_width}" if oembed_max_width
  request += "&maxheight=#{oembed_max_height}" if oembed_max_height
  request
end

#oembed_request_urlObject



96
97
98
# File 'lib/extractula/oembed.rb', line 96

def oembed_request_url
  url.url
end

#titleObject



100
101
102
# File 'lib/extractula/oembed.rb', line 100

def title
  oembed ? oembed.title : super
end

#video_embedObject



108
109
110
# File 'lib/extractula/oembed.rb', line 108

def video_embed
  oembed.html if oembed
end