Class: Metanorma::Mirror::Model::Node
- Inherits:
-
Object
- Object
- Metanorma::Mirror::Model::Node
- Defined in:
- lib/metanorma/mirror/model/node.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #accept_rewriter(_rewriter) ⇒ Object
- #container? ⇒ Boolean
-
#initialize(type:, attrs: {}) ⇒ Node
constructor
A new instance of Node.
- #leaf? ⇒ Boolean
- #text_content ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(type:, attrs: {}) ⇒ Node
Returns a new instance of Node.
9 10 11 12 |
# File 'lib/metanorma/mirror/model/node.rb', line 9 def initialize(type:, attrs: {}) @type = type @attrs = normalize_attrs(attrs) end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
7 8 9 |
# File 'lib/metanorma/mirror/model/node.rb', line 7 def attrs @attrs end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/metanorma/mirror/model/node.rb', line 7 def type @type end |
Instance Method Details
#accept_rewriter(_rewriter) ⇒ Object
32 33 34 35 |
# File 'lib/metanorma/mirror/model/node.rb', line 32 def accept_rewriter(_rewriter) raise NotImplementedError, "#{self.class}#accept_rewriter not implemented" end |
#container? ⇒ Boolean
24 25 26 |
# File 'lib/metanorma/mirror/model/node.rb', line 24 def container? false end |
#leaf? ⇒ Boolean
20 21 22 |
# File 'lib/metanorma/mirror/model/node.rb', line 20 def leaf? false end |
#text_content ⇒ Object
28 29 30 |
# File 'lib/metanorma/mirror/model/node.rb', line 28 def text_content "" end |
#to_h ⇒ Object
14 15 16 17 18 |
# File 'lib/metanorma/mirror/model/node.rb', line 14 def to_h h = { "type" => type } h["attrs"] = @attrs.dup unless @attrs.empty? h end |