Attributes
| [R] | source |
Class Public methods
from_html(html) Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 17 def from_html(html) new(ActionText::HtmlConversion.fragment_for_html(html.to_s.strip)) end
new(source) Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 24 def initialize(source) @source = source end
wrap(fragment_or_html) Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 6 def wrap(fragment_or_html) case fragment_or_html when self fragment_or_html when Nokogiri::HTML::DocumentFragment new(fragment_or_html) else from_html(fragment_or_html) end end
Instance Public methods
find_all(selector) Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 28 def find_all(selector) source.css(selector) end
replace(selector) Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 37 def replace(selector) update do |source| source.css(selector).each do |node| replacement_node = yield(node) node.replace(replacement_node.to_s) if node != replacement_node end end end
to_html() Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 50 def to_html @html ||= HtmlConversion.node_to_html(source) end
to_plain_text() Link
Source: show
# File actiontext/lib/action_text/fragment.rb, line 46 def to_plain_text @plain_text ||= PlainTextConversion.node_to_plain_text(source) end