Class: Lkml::Tree::SyntaxToken
- Inherits:
-
Object
- Object
- Lkml::Tree::SyntaxToken
show all
- Defined in:
- lib/lkml/tree.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value, line_number = nil, prefix = "", suffix = "", expr_suffix: nil) ⇒ SyntaxToken
Returns a new instance of SyntaxToken.
42
43
44
45
46
47
48
49
|
# File 'lib/lkml/tree.rb', line 42
def initialize(value, line_number = nil, prefix = "", suffix = "", expr_suffix: nil)
@value = value
@line_number = line_number
@prefix = prefix
@suffix = suffix
@expr_suffix = expr_suffix unless expr_suffix.nil?
freeze
end
|
Instance Attribute Details
#line_number ⇒ Object
Returns the value of attribute line_number.
40
41
42
|
# File 'lib/lkml/tree.rb', line 40
def line_number
@line_number
end
|
#prefix ⇒ Object
Returns the value of attribute prefix.
40
41
42
|
# File 'lib/lkml/tree.rb', line 40
def prefix
@prefix
end
|
#suffix ⇒ Object
Returns the value of attribute suffix.
40
41
42
|
# File 'lib/lkml/tree.rb', line 40
def suffix
@suffix
end
|
#value ⇒ Object
Returns the value of attribute value.
40
41
42
|
# File 'lib/lkml/tree.rb', line 40
def value
@value
end
|
Instance Method Details
#==(other) ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/lkml/tree.rb', line 59
def ==(other)
if instance_of?(other.class)
ivars_match?(other)
elsif other.is_a?(String)
@value == other
else
false
end
end
|
#accept(visitor) ⇒ Object
55
56
57
|
# File 'lib/lkml/tree.rb', line 55
def accept(visitor)
visitor.visit_token(self)
end
|
#eql?(other) ⇒ Boolean
69
70
71
|
# File 'lib/lkml/tree.rb', line 69
def eql?(other)
self == other
end
|
51
52
53
|
# File 'lib/lkml/tree.rb', line 51
def format_value
@value
end
|
#hash ⇒ Object
73
74
75
|
# File 'lib/lkml/tree.rb', line 73
def hash
instance_variables.map { |v| instance_variable_get(v) }.hash
end
|
#to_s ⇒ Object
77
78
79
|
# File 'lib/lkml/tree.rb', line 77
def to_s
Tree.items_to_str(@prefix, format_value, @suffix)
end
|
#with(**changes) ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'lib/lkml/tree.rb', line 81
def with(**changes)
self.class.new(
changes.fetch(:value, @value),
changes.fetch(:line_number, @line_number),
changes.fetch(:prefix, @prefix),
changes.fetch(:suffix, @suffix)
)
end
|