Class: Bade::AST::Node
Direct Known Subclasses
KeyValueNode, MixinCommonNode, StaticTextNode, TagNode, ValueNode
Instance Attribute Summary collapse
- #children ⇒ Array<Bade::AST::Node>
-
#filename ⇒ String
readonly
Filename.
-
#lineno ⇒ Int
readonly
Line number.
- #parent ⇒ Bade::AST::Node?
-
#type ⇒ Symbol
readonly
Type of this node.
Instance Method Summary collapse
- #==(other) ⇒ Bool
-
#initialize(type, parent = nil, lineno: nil, filename: nil) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(type, parent = nil, lineno: nil, filename: nil) ⇒ Node
Returns a new instance of Node.
31 32 33 34 35 36 37 |
# File 'lib/bade/ast/node.rb', line 31 def initialize(type, parent = nil, lineno: nil, filename: nil) @type = type @parent = parent @children = [] @lineno = lineno @filename = filename end |
Instance Attribute Details
#children ⇒ Array<Bade::AST::Node>
19 20 21 |
# File 'lib/bade/ast/node.rb', line 19 def children @children end |
#filename ⇒ String (readonly)
Returns filename.
29 30 31 |
# File 'lib/bade/ast/node.rb', line 29 def filename @filename end |
#lineno ⇒ Int (readonly)
Returns line number.
25 26 27 |
# File 'lib/bade/ast/node.rb', line 25 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
52 53 54 55 56 |
# File 'lib/bade/ast/node.rb', line 52 def ==(other) return false unless self.class == other.class type == other.type && children == other.children end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/bade/ast/node.rb', line 44 def inspect to_s end |
#to_s ⇒ Object
39 40 41 42 |
# File 'lib/bade/ast/node.rb', line 39 def to_s require_relative 'string_serializer' StringSerializer.new(self).to_s end |