Class: DraftjsHtml::Node
- Inherits:
-
Struct
- Object
- Struct
- DraftjsHtml::Node
- Defined in:
- lib/draftjs_html/node.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#content ⇒ Object
Returns the value of attribute content.
-
#element_name ⇒ Object
Returns the value of attribute element_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes
37 38 39 |
# File 'lib/draftjs_html/node.rb', line 37 def attributes @attributes end |
#content ⇒ Object
Returns the value of attribute content
37 38 39 |
# File 'lib/draftjs_html/node.rb', line 37 def content @content end |
#element_name ⇒ Object
Returns the value of attribute element_name
37 38 39 |
# File 'lib/draftjs_html/node.rb', line 37 def element_name @element_name end |
Class Method Details
.of(thing) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/draftjs_html/node.rb', line 38 def self.of(thing) case thing when Nokogiri::XML::Node then NokogiriNode.new(thing) when self.class then thing when String then StringNode.new(thing) else thing end end |
Instance Method Details
#to_nokogiri(document) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/draftjs_html/node.rb', line 47 def to_nokogiri(document) Nokogiri::XML::Node.new(element_name, document).tap do |node| node << content.to_nokogiri(document) if content (attributes || {}).each { |k, v| node[k] = v } end end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/draftjs_html/node.rb', line 58 def to_s content.to_s end |
#wrap(tagname, attrs = {}) ⇒ Object
54 55 56 |
# File 'lib/draftjs_html/node.rb', line 54 def wrap(tagname, attrs = {}) Node.new(tagname, attrs, self) end |