Class: Lkml::Tree::BlockNode
- Inherits:
-
SyntaxNode
- Object
- SyntaxNode
- Lkml::Tree::BlockNode
- Defined in:
- lib/lkml/tree.rb
Instance Attribute Summary collapse
-
#colon ⇒ Object
readonly
Returns the value of attribute colon.
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#left_brace ⇒ Object
readonly
Returns the value of attribute left_brace.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#right_brace ⇒ Object
readonly
Returns the value of attribute right_brace.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #children ⇒ Object
-
#initialize(type:, left_brace: nil, right_brace: nil, colon: nil, name: nil, container: nil) ⇒ BlockNode
constructor
A new instance of BlockNode.
- #inspect ⇒ Object
- #line_number ⇒ Object
- #to_s ⇒ Object
- #with(**changes) ⇒ Object
Constructor Details
#initialize(type:, left_brace: nil, right_brace: nil, colon: nil, name: nil, container: nil) ⇒ BlockNode
Returns a new instance of BlockNode.
353 354 355 356 357 358 359 360 361 362 |
# File 'lib/lkml/tree.rb', line 353 def initialize(type:, left_brace: nil, right_brace: nil, colon: nil, name: nil, container: nil) super() @type = type @left_brace = left_brace || LeftCurlyBrace.new("{", nil, "", "\n") @right_brace = right_brace || RightCurlyBrace.new("}", nil, "\n", "") @colon = colon || Colon.new(":", nil, "", " ") @name = name @container = container || ContainerNode.new(items: []) freeze end |
Instance Attribute Details
#colon ⇒ Object (readonly)
Returns the value of attribute colon.
351 352 353 |
# File 'lib/lkml/tree.rb', line 351 def colon @colon end |
#container ⇒ Object (readonly)
Returns the value of attribute container.
351 352 353 |
# File 'lib/lkml/tree.rb', line 351 def container @container end |
#left_brace ⇒ Object (readonly)
Returns the value of attribute left_brace.
351 352 353 |
# File 'lib/lkml/tree.rb', line 351 def left_brace @left_brace end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
351 352 353 |
# File 'lib/lkml/tree.rb', line 351 def name @name end |
#right_brace ⇒ Object (readonly)
Returns the value of attribute right_brace.
351 352 353 |
# File 'lib/lkml/tree.rb', line 351 def right_brace @right_brace end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
351 352 353 |
# File 'lib/lkml/tree.rb', line 351 def type @type end |
Instance Method Details
#==(other) ⇒ Object
398 399 400 401 402 403 404 405 406 |
# File 'lib/lkml/tree.rb', line 398 def ==(other) instance_of?(other.class) && @type == other.type && @left_brace == other.left_brace && @right_brace == other.right_brace && @colon == other.colon && @name == other.name && @container == other.container end |
#accept(visitor) ⇒ Object
377 378 379 |
# File 'lib/lkml/tree.rb', line 377 def accept(visitor) visitor.visit_block(self) end |
#children ⇒ Object
369 370 371 |
# File 'lib/lkml/tree.rb', line 369 def children @container.children end |
#inspect ⇒ Object
364 365 366 367 |
# File 'lib/lkml/tree.rb', line 364 def inspect nm = @name ? "name='#{@name.value}'" : "None" "#{self.class.name.split('::').last}(type='#{@type.value}', #{nm})" end |
#line_number ⇒ Object
373 374 375 |
# File 'lib/lkml/tree.rb', line 373 def line_number @type.line_number end |
#to_s ⇒ Object
381 382 383 384 385 |
# File 'lib/lkml/tree.rb', line 381 def to_s nm = @name || "" ctr = @container || "" Tree.items_to_str(@type, @colon, nm, @left_brace, ctr, @right_brace) end |
#with(**changes) ⇒ Object
387 388 389 390 391 392 393 394 395 396 |
# File 'lib/lkml/tree.rb', line 387 def with(**changes) BlockNode.new( type: changes.fetch(:type, @type), left_brace: changes.fetch(:left_brace, @left_brace), right_brace: changes.fetch(:right_brace, @right_brace), colon: changes.fetch(:colon, @colon), name: changes.fetch(:name, @name), container: changes.fetch(:container, @container) ) end |