Class: Prismic::Fragments::Slice
- Defined in:
 - lib/prismic/fragments/slices.rb
 
Overview
A fragment of type Slice, 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)  ⇒ Slice 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Slice.
 
Constructor Details
#initialize(slice_type, slice_label, value) ⇒ Slice
Returns a new instance of Slice
      11 12 13 14 15  | 
    
      # File 'lib/prismic/fragments/slices.rb', line 11 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
      8 9 10  | 
    
      # File 'lib/prismic/fragments/slices.rb', line 8 def slice_label @slice_label end  | 
  
#slice_type ⇒ Object
Returns the value of attribute slice_type
      7 8 9  | 
    
      # File 'lib/prismic/fragments/slices.rb', line 7 def slice_type @slice_type end  | 
  
#value ⇒ Object
Returns the value of attribute value
      9 10 11  | 
    
      # File 'lib/prismic/fragments/slices.rb', line 9 def value @value end  | 
  
Instance Method Details
#as_html(link_resolver = nil) ⇒ String
Generate an HTML representation of the group
      30 31 32 33 34 35 36  | 
    
      # File 'lib/prismic/fragments/slices.rb', line 30 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
      20 21 22  | 
    
      # File 'lib/prismic/fragments/slices.rb', line 20 def as_text @value.as_text end  |