Class: Prismic::Fragments::SimpleSlice

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

Overview

A fragment of type SimpleSlice, an item in a SliceZone

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slice_type, slice_label, value) ⇒ SimpleSlice

Returns a new instance of SimpleSlice.



60
61
62
63
64
# File 'lib/prismic/fragments/slices.rb', line 60

def initialize(slice_type, slice_label, value)
  @slice_type = slice_type
  @slice_label = slice_label
  @value = value
end

Instance Attribute Details

#slice_labelObject

Returns the value of attribute slice_label.



57
58
59
# File 'lib/prismic/fragments/slices.rb', line 57

def slice_label
  @slice_label
end

#slice_typeObject

Returns the value of attribute slice_type.



56
57
58
# File 'lib/prismic/fragments/slices.rb', line 56

def slice_type
  @slice_type
end

#valueObject

Returns the value of attribute value.



58
59
60
# File 'lib/prismic/fragments/slices.rb', line 58

def value
  @value
end

Instance Method Details

#as_html(link_resolver = nil) ⇒ String

Generate an HTML representation of the group

Parameters:

  • link_resolver (LinkResolver) (defaults to: nil)

    The LinkResolver used to build application's specific URL

Returns:

  • (String)

    the HTML representation



79
80
81
82
83
84
85
# File 'lib/prismic/fragments/slices.rb', line 79

def as_html(link_resolver=nil)
  classes = ['slice']
  unless (@slice_label.nil?)
    classes.push(@slice_label)
  end
  %[<div data-slicetype="#{@slice_type}" class="#{classes.join(' ')}">#{@value.as_html(link_resolver)}</div>]
end

#as_textString

Generate an text representation of the group

Returns:

  • (String)

    the text representation



69
70
71
# File 'lib/prismic/fragments/slices.rb', line 69

def as_text
  @value.as_text
end