Class: Lkml::Tree::DocumentNode

Inherits:
SyntaxNode show all
Defined in:
lib/lkml/tree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, prefix = "", suffix = "") ⇒ DocumentNode

Returns a new instance of DocumentNode.



412
413
414
415
416
417
418
# File 'lib/lkml/tree.rb', line 412

def initialize(container, prefix = "", suffix = "")
  super()
  @container = container
  @prefix = prefix
  @suffix = suffix
  freeze
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



410
411
412
# File 'lib/lkml/tree.rb', line 410

def container
  @container
end

#prefixObject (readonly)

Returns the value of attribute prefix.



410
411
412
# File 'lib/lkml/tree.rb', line 410

def prefix
  @prefix
end

#suffixObject (readonly)

Returns the value of attribute suffix.



410
411
412
# File 'lib/lkml/tree.rb', line 410

def suffix
  @suffix
end

Instance Method Details

#accept(visitor) ⇒ Object



428
429
430
# File 'lib/lkml/tree.rb', line 428

def accept(visitor)
  visitor.visit(self)
end

#childrenObject



420
421
422
# File 'lib/lkml/tree.rb', line 420

def children
  [@container]
end

#line_numberObject



424
425
426
# File 'lib/lkml/tree.rb', line 424

def line_number
  1
end

#to_sObject



432
433
434
# File 'lib/lkml/tree.rb', line 432

def to_s
  Tree.items_to_str(@prefix, @container, @suffix)
end

#with(**changes) ⇒ Object



436
437
438
439
440
441
442
# File 'lib/lkml/tree.rb', line 436

def with(**changes)
  DocumentNode.new(
    changes.fetch(:container, @container),
    changes.fetch(:prefix, @prefix),
    changes.fetch(:suffix, @suffix)
  )
end