Class: Prismic::Fragments::Group
- Inherits:
-
Fragment
- Object
- Fragment
- 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)
-
- (Object) group_documents
The array of group documents.
Instance Method Summary (collapse)
-
- (Prismic::WithFragments) [](index)
(also: #get)
Get the group document corresponding to index.
-
- (String) as_html(link_resolver = nil)
Generate an HTML representation of the group.
-
- (String) as_text
Generate an text representation of the group.
- - (Object) each {|group_doc| ... }
-
- (Group) initialize(group_documents)
constructor
A new instance of Group.
- - (Object) length (also: #size)
Constructor Details
- (Group) initialize(group_documents)
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
- (Object) group_documents
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
- (Prismic::WithFragments) [](index) 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 |
- (String) as_html(link_resolver = nil)
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 |
- (String) as_text
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 |
- (Object) each {|group_doc| ... }
45 46 47 |
# File 'lib/prismic/fragments/group.rb', line 45 def each(&blk) @group_documents.each(&blk) end |
- (Object) length Also known as: size
50 51 52 |
# File 'lib/prismic/fragments/group.rb', line 50 def length @group_documents.length end |