Class: Bade::AST::Node
- Inherits:
-
Object
- Object
- Bade::AST::Node
- Defined in:
- lib/bade/ast/node.rb
Direct Known Subclasses
KeyValueNode, MixinCommonNode, StaticTextNode, TagNode, ValueNode
Instance Attribute Summary collapse
- #children ⇒ Array<Bade::Node>
-
#lineno ⇒ Int
readonly
Line number.
-
#type ⇒ Symbol
readonly
Type of this node.
Instance Method Summary collapse
- #==(other) ⇒ Bool
-
#initialize(type, lineno: nil) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, lineno: nil) ⇒ Node
Returns a new instance of Node.
23 24 25 26 27 28 |
# File 'lib/bade/ast/node.rb', line 23 def initialize(type, lineno: nil) @type = type @children = [] @lineno = lineno end |
Instance Attribute Details
#children ⇒ Array<Bade::Node>
15 16 17 |
# File 'lib/bade/ast/node.rb', line 15 def children @children end |
#lineno ⇒ Int (readonly)
Returns line number.
21 22 23 |
# File 'lib/bade/ast/node.rb', line 21 def lineno @lineno end |
#type ⇒ Symbol (readonly)
Returns type of this node.
11 12 13 |
# File 'lib/bade/ast/node.rb', line 11 def type @type end |
Instance Method Details
#==(other) ⇒ Bool
43 44 45 46 47 |
# File 'lib/bade/ast/node.rb', line 43 def ==(other) return false unless self.class == other.class type == other.type && children == other.children end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/bade/ast/node.rb', line 35 def inspect to_s end |
#to_s ⇒ Object
30 31 32 33 |
# File 'lib/bade/ast/node.rb', line 30 def to_s require_relative 'string_serializer' StringSerializer.new(self).to_s end |