Class: Prismic::Fragments::Group
- Includes:
 - Enumerable
 
- Defined in:
 - lib/prismic/fragments/group.rb
 
Overview
A fragment of type Group, which contains an array of FragmentList (which itself is a Hash of fragments).
For instance, imagining this group is defined with two possible fragments:
an image fragment "image", and a text fragment "caption"; then accessing
the first image will look like this: group[0]['image'].
Instance Attribute Summary collapse
- 
  
    
      #group_documents  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The array of group documents.
 
Instance Method Summary collapse
- 
  
    
      #[](index)  ⇒ Prismic::WithFragments 
    
    
      (also: #get)
    
  
  
  
  
  
  
  
  
  
    
Get the group document corresponding to index.
 - 
  
    
      #as_html(link_resolver = nil)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Generate an HTML representation of the group.
 - 
  
    
      #as_text  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Generate an text representation of the group.
 - #each {|group_doc| ... } ⇒ Object
 - 
  
    
      #initialize(group_documents)  ⇒ Group 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Group.
 - #length ⇒ Object (also: #size)
 
Constructor Details
#initialize(group_documents) ⇒ Group
Returns a new instance of Group
      33 34 35  | 
    
      # File 'lib/prismic/fragments/group.rb', line 33 def initialize(group_documents) @group_documents = group_documents end  | 
  
Instance Attribute Details
#group_documents ⇒ Object
The array of group documents
      31 32 33  | 
    
      # File 'lib/prismic/fragments/group.rb', line 31 def group_documents @group_documents end  | 
  
Instance Method Details
#[](index) ⇒ Prismic::WithFragments Also known as: get
Get the group document corresponding to index
      39 40 41  | 
    
      # File 'lib/prismic/fragments/group.rb', line 39 def [](index) @group_documents[index] end  | 
  
#as_html(link_resolver = nil) ⇒ String
Generate an HTML representation of the group
      61 62 63  | 
    
      # File 'lib/prismic/fragments/group.rb', line 61 def as_html(link_resolver = nil) @group_documents.map { |doc| doc.as_html(link_resolver) }.join("\n") end  | 
  
#as_text ⇒ String
Generate an text representation of the group
      68 69 70  | 
    
      # File 'lib/prismic/fragments/group.rb', line 68 def as_text @group_documents.map { |doc| doc.as_text }.join("\n") end  | 
  
#each {|group_doc| ... } ⇒ Object
      45 46 47  | 
    
      # File 'lib/prismic/fragments/group.rb', line 45 def each(&blk) @group_documents.each(&blk) end  | 
  
#length ⇒ Object Also known as: size
      50 51 52  | 
    
      # File 'lib/prismic/fragments/group.rb', line 50 def length @group_documents.length end  |