Class: ActionText::AttachmentGallery
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
#slice, #values_at
#persisted?
#to_key, #to_model, #to_param, #to_partial_path
#errors, #freeze, #initialize_dup, #invalid?, #valid?, #validate!, #validates_with, #validation_context
#assign_attributes, #attribute_writer_missing
Constructor Details
Returns a new instance of AttachmentGallery.
54
55
56
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 54
def initialize(node)
@node = node
end
|
Instance Attribute Details
Returns the value of attribute node.
52
53
54
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 52
def node
@node
end
|
Class Method Details
.attachment_selector ⇒ Object
43
44
45
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 43
def attachment_selector
"#{ActionText::Attachment.tag_name}[presentation=gallery]"
end
|
.find_attachment_gallery_nodes(content) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 27
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) ⇒ Object
13
14
15
16
17
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 13
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) ⇒ Object
19
20
21
22
23
24
25
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 19
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) ⇒ Object
39
40
41
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 39
def from_node(node)
new(node)
end
|
47
48
49
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 47
def selector
"#{TAG_NAME}:has(#{attachment_selector} + #{attachment_selector})"
end
|
Instance Method Details
68
69
70
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 68
def inspect
"#<#{self.class.name} size=#{size.inspect}>"
end
|
64
65
66
|
# File 'actiontext/lib/action_text/attachment_gallery.rb', line 64
def size
attachments.size
end
|