Class: ActionText::Fragment
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actiontext/lib/action_text/fragment.rb |
Class Method Summary
Instance Attribute Summary
- #deconstruct readonly
- #source readonly
Instance Method Summary
Constructor Details
.new(source) ⇒ Fragment
Class Method Details
.from_html(html)
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 19
def from_html(html) new(ActionText::HtmlConversion.fragment_for_html(html.to_s.strip)) end
.wrap(fragment_or_html)
[ GitHub ]Instance Attribute Details
#deconstruct (readonly)
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 26
delegate :deconstruct, to: "source.elements"
#source (readonly)
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 24
attr_reader :source
Instance Method Details
#find_all(selector)
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 32
def find_all(selector) source.css(selector) end
#replace(selector)
[ GitHub ]#to_html
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 54
def to_html @html ||= HtmlConversion.node_to_html(source) end
#to_plain_text
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 50
def to_plain_text @plain_text ||= PlainTextConversion.node_to_plain_text(source) end
#to_s
[ GitHub ]# File 'actiontext/lib/action_text/fragment.rb', line 58
def to_s to_html end