Class: Bade::AST::Document
- Inherits:
-
Object
- Object
- Bade::AST::Document
- Defined in:
- lib/bade/ast/document.rb
Instance Attribute Summary collapse
-
#file_path ⇒ String?
readonly
Path to this document, but only if it is defined from file.
-
#root ⇒ Bade::Node
readonly
Root node of this document.
- #sub_documents ⇒ Array<Bade::Document> readonly
Instance Method Summary collapse
- #==(other) ⇒ Bool
- #freeze ⇒ Object
-
#initialize(root: Node.new(:root), file_path: nil) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(root: Node.new(:root), file_path: nil) ⇒ Document
Returns a new instance of Document.
27 28 29 30 31 32 |
# File 'lib/bade/ast/document.rb', line 27 def initialize(root: Node.new(:root), file_path: nil) @root = root @file_path = file_path.dup.freeze unless file_path.nil? @sub_documents = [] end |
Instance Attribute Details
#file_path ⇒ String? (readonly)
Path to this document, but only if it is defined from file
19 20 21 |
# File 'lib/bade/ast/document.rb', line 19 def file_path @file_path end |
#root ⇒ Bade::Node (readonly)
Root node of this document
13 14 15 |
# File 'lib/bade/ast/document.rb', line 13 def root @root end |
#sub_documents ⇒ Array<Bade::Document> (readonly)
23 24 25 |
# File 'lib/bade/ast/document.rb', line 23 def sub_documents @sub_documents end |
Instance Method Details
#==(other) ⇒ Bool
46 47 48 49 50 |
# File 'lib/bade/ast/document.rb', line 46 def ==(other) return false unless other.is_a?(Document) root == other.root && sub_documents == other.sub_documents end |
#freeze ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/bade/ast/document.rb', line 34 def freeze super root.freeze sub_documents.freeze sub_documents.each(&:freeze) end |