Methods
- attachment_selector
- attachments
- find_attachment_gallery_nodes
- fragment_by_canonicalizing_attachment_galleries
- fragment_by_replacing_attachment_gallery_nodes
- from_node
- inspect
- new
- selector
- size
Included Modules
Attributes
[R] | node |
Class Public methods
attachment_selector()
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 41
def attachment_selector
"#{ActionText::Attachment.tag_name}[presentation=gallery]"
end
🔎 See on GitHub
find_attachment_gallery_nodes(content)
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 25
def find_attachment_gallery_nodes(content)
Fragment.wrap(content).find_all(selector).select do |node|
node.children.all? do |child|
if child.text?
/\A(\n|\ )*\z/.match?(child.text)
else
child.matches? attachment_selector
end
end
end
end
🔎 See on GitHub
fragment_by_canonicalizing_attachment_galleries(content)
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 11
def fragment_by_canonicalizing_attachment_galleries(content)
fragment_by_replacing_attachment_gallery_nodes(content) do |node|
"<#{TAG_NAME}>#{node.inner_html}</#{TAG_NAME}>"
end
end
🔎 See on GitHub
fragment_by_replacing_attachment_gallery_nodes(content)
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 17
def fragment_by_replacing_attachment_gallery_nodes(content)
Fragment.wrap(content).update do |source|
find_attachment_gallery_nodes(source).each do |node|
node.replace(yield(node).to_s)
end
end
end
🔎 See on GitHub
from_node(node)
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 37
def from_node(node)
new(node)
end
🔎 See on GitHub
new(node)
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 52
def initialize(node)
@node = node
end
🔎 See on GitHub
selector()
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 45
def selector
"#{TAG_NAME}:has(#{attachment_selector} + #{attachment_selector})"
end
🔎 See on GitHub
Instance Public methods
attachments()
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 56
def attachments
@attachments ||= node.css(ActionText::AttachmentGallery.attachment_selector).map do |node|
ActionText::Attachment.from_node(node).with_full_attributes
end
end
🔎 See on GitHub
inspect()
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 66
def inspect
"#<#{self.class.name} size=#{size.inspect}>"
end
🔎 See on GitHub
size()
📝 Source code
# File actiontext/lib/action_text/attachment_gallery.rb, line 62
def size
attachments.size
end
🔎 See on GitHub