Class: Prismic::Fragments::Embed

Inherits:
Fragment
  • Object
show all
Defined in:
lib/prismic/fragments/embed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Fragment

#as_text

Constructor Details

#initialize(embed_type, provider, url, html, o_embed_json) ⇒ Embed

Returns a new instance of Embed.



7
8
9
10
11
12
13
# File 'lib/prismic/fragments/embed.rb', line 7

def initialize(embed_type, provider, url, html, o_embed_json)
  @embed_type   = embed_type
  @provider     = provider
  @url          = url
  @html         = html
  @o_embed_json = o_embed_json
end

Instance Attribute Details

#embed_typeObject

Returns the value of attribute embed_type.



5
6
7
# File 'lib/prismic/fragments/embed.rb', line 5

def embed_type
  @embed_type
end

#htmlObject

Returns the value of attribute html.



5
6
7
# File 'lib/prismic/fragments/embed.rb', line 5

def html
  @html
end

#o_embed_jsonObject

Returns the value of attribute o_embed_json.



5
6
7
# File 'lib/prismic/fragments/embed.rb', line 5

def o_embed_json
  @o_embed_json
end

#providerObject

Returns the value of attribute provider.



5
6
7
# File 'lib/prismic/fragments/embed.rb', line 5

def provider
  @provider
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/prismic/fragments/embed.rb', line 5

def url
  @url
end

Instance Method Details

#as_html(link_resolver = nil, html_serializer = nil) ⇒ String

Generate an HTML representation of the fragment

Parameters:

  • link_resolver (LinkResolver) (defaults to: nil)

    The LinkResolver used to build application's specific URL

Returns:

  • (String)

    the HTML representation



21
22
23
# File 'lib/prismic/fragments/embed.rb', line 21

def as_html(link_resolver=nil, html_serializer=nil)
  %Q|<div data-oembed="#{@url}" data-oembed-type="#{@embed_type.downcase}" data-oembed-provider="#{@provider.downcase}">#@html</div>|
end