Class: DraftjsHtml::StringNode
- Inherits:
-
Struct
- Object
- Struct
- DraftjsHtml::StringNode
- Defined in:
- lib/draftjs_html/node.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
Instance Method Summary collapse
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw
16 17 18 |
# File 'lib/draftjs_html/node.rb', line 16 def raw @raw end |
Instance Method Details
#to_nokogiri(document) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/draftjs_html/node.rb', line 17 def to_nokogiri(document) lines = raw.lines text_nodes = lines.flat_map.with_index do |text, i| nodes = [Nokogiri::XML::Text.new(text.chomp, document)] nodes << Nokogiri::XML::Node.new('br', document) if text.end_with?("\n") nodes end Nokogiri::XML::NodeSet.new(document, text_nodes) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/draftjs_html/node.rb', line 32 def to_s raw.to_s end |
#wrap(tagname, attrs = {}) ⇒ Object
28 29 30 |
# File 'lib/draftjs_html/node.rb', line 28 def wrap(tagname, attrs = {}) Node.new(tagname, attrs, self) end |