class SyntaxTree::CHAR
CHAR
irepresents a single codepoint in the script encoding.
?a
In
the example above, the CHAR
node represents the string literal “a”. You can use control characters with this as well, as in ?C-a.
Attributes
- String
-
the value of the character literal
Public Class Methods
Source
# File lib/syntax_tree/node.rb, line 255 def initialize(value:, location:) @value = value @location = location @comments = [] end
Public Instance Methods
Source
# File lib/syntax_tree/node.rb, line 296 def ===(other) other.is_a?(CHAR) && value === other.value end
Source
# File lib/syntax_tree/node.rb, line 261 def accept(visitor) visitor.visit_CHAR(self) end
Source
# File lib/syntax_tree/node.rb, line 269 def copy(value: nil, location: nil) node = CHAR.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 282 def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
Source
# File lib/syntax_tree/node.rb, line 286 def format(q) if value.length != 2 q.text(value) else q.text(q.quote) q.text(value[1] == q.quote ? "\\#{q.quote}" : value[1]) q.text(q.quote) end end