class SyntaxTree::Defined
Defined
represents the use of the defined?
operator. It can be used with and without parentheses.
defined?(variable)
Attributes
value[R]
Node
-
the value being sent to the keyword
Public Class Methods
new(value:, location:)
click to toggle source
# File lib/syntax_tree/node.rb, line 4256 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
===(other)
click to toggle source
# File lib/syntax_tree/node.rb, line 4299 def ===(other) other.is_a?(Defined) && value === other.value end
accept(visitor)
click to toggle source
# File lib/syntax_tree/node.rb, line 4262 def accept(visitor) visitor.visit_defined(self) end
child_nodes()
click to toggle source
# File lib/syntax_tree/node.rb, line 4266 def child_nodes [value] end
Also aliased as: deconstruct
copy(value: nil, location: nil)
click to toggle source
# File lib/syntax_tree/node.rb, line 4270 def copy(value: nil, location: nil) node = Defined.new( value: value || self.value, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node end
deconstruct_keys(_keys)
click to toggle source
# File lib/syntax_tree/node.rb, line 4283 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
format(q)
click to toggle source
# File lib/syntax_tree/node.rb, line 4287 def format(q) q.text("defined?(") q.group do q.indent do q.breakable_empty q.format(value) end q.breakable_empty end q.text(")") end