class SyntaxTree::Int
1
Int represents an integer number literal.
def ===(other)
def ===(other) other.is_a?(Int) && value === other.value end
def accept(visitor)
def accept(visitor) visitor.visit_int(self) end
def child_nodes
def child_nodes [] end
def copy(value: nil, location: nil)
def copy(value: nil, location: nil) node = Int.new(value: value || self.value, location: location || self.location) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
def format(q)
def format(q) if !value.start_with?(/\+?0/) && value.length >= 5 && !value.include?("_") # If it's a plain integer and it doesn't have any underscores separating # the values, then we're going to insert them every 3 characters # starting from the right. index = (value.length + 2) % 3 q.text(" #{value}"[index..].scan(/.../).join("_").strip) else q.text(value) end end
def initialize(value:, location:)
def initialize(value:, location:) @value = value @location = location @comments = [] end