class SyntaxTree::Defined
Defined
represents the use of the defined?
operator. It can be used with and without parentheses.
defined?(variable)
Attributes
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 4271 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 4314 def ===(other) other.is_a?(Defined) && value === other.value end
Source
# File lib/syntax_tree/node.rb, line 4277 def accept(visitor) visitor.visit_defined(self) end
Source
# File lib/syntax_tree/node.rb, line 4281 def child_nodes [value] end
Also aliased as: deconstruct
Source
# File lib/syntax_tree/node.rb, line 4285 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
Source
# File lib/syntax_tree/node.rb, line 4298 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 4302 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