Class: Prismic::Fragments::SimpleSlice
- Defined in:
- lib/prismic/fragments/slices.rb
Overview
A fragment of type SimpleSlice, an item in a SliceZone
Instance Attribute Summary collapse
-
#slice_label ⇒ Object
Returns the value of attribute slice_label.
-
#slice_type ⇒ Object
Returns the value of attribute slice_type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#as_html(link_resolver = nil) ⇒ String
Generate an HTML representation of the group.
-
#as_text ⇒ String
Generate an text representation of the group.
-
#initialize(slice_type, slice_label, value) ⇒ SimpleSlice
constructor
A new instance of SimpleSlice.
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_label ⇒ Object
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_type ⇒ Object
Returns the value of attribute slice_type.
56 57 58 |
# File 'lib/prismic/fragments/slices.rb', line 56 def slice_type @slice_type end |
#value ⇒ Object
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
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_text ⇒ String
Generate an text representation of the group
69 70 71 |
# File 'lib/prismic/fragments/slices.rb', line 69 def as_text @value.as_text end |