class ActionText::AttachmentGallery
Constants
- ATTACHMENT_SELECTOR
- SELECTOR
- TAG_NAME
Attributes
node[R]
Public Class Methods
find_attachment_gallery_nodes(content)
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 22 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
fragment_by_canonicalizing_attachment_galleries(content)
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 8 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
fragment_by_replacing_attachment_gallery_nodes(content) { |node| ... }
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 14 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
from_node(node)
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 34 def from_node(node) new(node) end
new(node)
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 41 def initialize(node) @node = node end
Public Instance Methods
attachments()
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 45 def attachments @attachments ||= node.css(ATTACHMENT_SELECTOR).map do |node| ActionText::Attachment.from_node(node).with_full_attributes end end
inspect()
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 55 def inspect "#<#{self.class.name} size=#{size.inspect}>" end
size()
click to toggle source
# File lib/action_text/attachment_gallery.rb, line 51 def size attachments.size end