class ActionText::AttachmentGallery

def attachment_selector

def attachment_selector
  "#{ActionText::Attachment.tag_name}[presentation=gallery]"
end

def attachments

def attachments
  @attachments ||= node.css(ActionText::AttachmentGallery.attachment_selector).map do |node|
    ActionText::Attachment.from_node(node).with_full_attributes
  end
end

def find_attachment_gallery_nodes(content)

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

def fragment_by_canonicalizing_attachment_galleries(content)

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

def fragment_by_replacing_attachment_gallery_nodes(content)

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

def from_node(node)

def from_node(node)
  new(node)
end

def initialize(node)

def initialize(node)
  @node = node
end

def inspect

def inspect
  "#<#{self.class.name} size=#{size.inspect}>"
end

def selector

def selector
  "#{TAG_NAME}:has(#{attachment_selector} + #{attachment_selector})"
end

def size

def size
  attachments.size
end