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

- (Embed) initialize(embed_type, provider, url, html, o_embed_json)

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

- (Object) embed_type

Returns the value of attribute embed_type



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

def embed_type
  @embed_type
end

- (Object) html

Returns the value of attribute html



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

def html
  @html
end

- (Object) o_embed_json

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

- (Object) provider

Returns the value of attribute provider



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

def provider
  @provider
end

- (Object) url

Returns the value of attribute url



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

def url
  @url
end

Instance Method Details

- (String) as_html(link_resolver = nil, html_serializer = nil)

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