Class: Lkml::Tree::PairNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value:, colon: nil) ⇒ PairNode

Returns a new instance of PairNode.



184
185
186
187
188
189
190
# File 'lib/lkml/tree.rb', line 184

def initialize(type:, value:, colon: nil)
  super()
  @type = type
  @value = value
  @colon = colon || Colon.new(":", nil, "", " ")
  freeze
end

Instance Attribute Details

#colonObject (readonly)

Returns the value of attribute colon.



182
183
184
# File 'lib/lkml/tree.rb', line 182

def colon
  @colon
end

#typeObject (readonly)

Returns the value of attribute type.



182
183
184
# File 'lib/lkml/tree.rb', line 182

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



182
183
184
# File 'lib/lkml/tree.rb', line 182

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



220
221
222
223
224
225
# File 'lib/lkml/tree.rb', line 220

def ==(other)
  instance_of?(other.class) &&
    @type == other.type &&
    @value == other.value &&
    @colon == other.colon
end

#accept(visitor) ⇒ Object



204
205
206
# File 'lib/lkml/tree.rb', line 204

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

#childrenObject



196
197
198
# File 'lib/lkml/tree.rb', line 196

def children
  nil
end

#inspectObject



192
193
194
# File 'lib/lkml/tree.rb', line 192

def inspect
  "#{self.class.name.split('::').last}(type='#{@type.value}', value='#{@value.value}')"
end

#line_numberObject



200
201
202
# File 'lib/lkml/tree.rb', line 200

def line_number
  @type.line_number
end

#to_sObject



208
209
210
# File 'lib/lkml/tree.rb', line 208

def to_s
  Tree.items_to_str(@type, @colon, @value)
end

#with(**changes) ⇒ Object



212
213
214
215
216
217
218
# File 'lib/lkml/tree.rb', line 212

def with(**changes)
  PairNode.new(
    type: changes.fetch(:type, @type),
    value: changes.fetch(:value, @value),
    colon: changes.fetch(:colon, @colon)
  )
end