class Prismic::Fragments::Group
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['image']`.
Attributes
group_documents[RW]
The array of group documents
Public Class Methods
new(group_documents)
click to toggle source
# File lib/prismic/fragments/group.rb, line 33 def initialize(group_documents) @group_documents = group_documents end
Public Instance Methods
[](index)
click to toggle source
Get the group document corresponding to index @return [Prismic::WithFragments]
# File lib/prismic/fragments/group.rb, line 39 def [](index) @group_documents[index] end
Also aliased as: get
as_html(link_resolver = nil)
click to toggle source
Generate an HTML representation of the group
@param link_resolver [LinkResolver] The LinkResolver
used to build
application's specific URL
@return [String] the HTML representation
# 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()
click to toggle source
Generate an text representation of the group
@return [String] the text representation
# File lib/prismic/fragments/group.rb, line 68 def as_text @group_documents.map { |doc| doc.as_text }.join("\n") end
each(&blk)
click to toggle source
@yieldparam group_doc [WithFragment]
# File lib/prismic/fragments/group.rb, line 45 def each(&blk) @group_documents.each(&blk) end
length()
click to toggle source
# File lib/prismic/fragments/group.rb, line 50 def length @group_documents.length end
Also aliased as: size