Class: OembedReceiver
- Inherits:
-
Object
- Object
- OembedReceiver
- Defined in:
- app/services/oembed_receiver.rb
Overview
Receiver for OEmbed-wrapped content
Constant Summary collapse
- PATTERN =
%r{<oembed url="([^"]+)"></oembed>}.freeze
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #code ⇒ Object
- #fallback ⇒ Object
-
#initialize(url = '') ⇒ OembedReceiver
constructor
A new instance of OembedReceiver.
Constructor Details
#initialize(url = '') ⇒ OembedReceiver
Returns a new instance of OembedReceiver.
10 11 12 |
# File 'app/services/oembed_receiver.rb', line 10 def initialize(url = '') @url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'app/services/oembed_receiver.rb', line 7 def url @url end |
Class Method Details
Instance Method Details
#code ⇒ Object
23 24 25 26 |
# File 'app/services/oembed_receiver.rb', line 23 def code @host = URI.parse(@url).host receive url_for_host end |
#fallback ⇒ Object
28 29 30 31 |
# File 'app/services/oembed_receiver.rb', line 28 def fallback attributes = %(rel="external nofollow noopener noreferrer" target="_blank") %(<a href="#{@url}" #{attributes}>#{@host}</a>) end |