Class: Prism::IntegerNode

Inherits:
PrismNode
  • Object
show all
Defined in:
lib/prism/node.rb,
ext/prism/api_node.c

Overview

Represents an integer number literal.

1
^

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, value) ⇒ IntegerNode

Initialize a new IntegerNode node.



10388
10389
10390
10391
10392
10393
10394
# File 'lib/prism/node.rb', line 10388

def initialize(source, node_id, location, flags, value)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

The value of the integer literal as a number.



10450
10451
10452
# File 'lib/prism/node.rb', line 10450

def value
  @value
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See ‘Node::type`.



10463
10464
10465
# File 'lib/prism/node.rb', line 10463

def self.type
  :integer_node
end

Instance Method Details

#===(other) ⇒ Object

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.



10469
10470
10471
10472
10473
# File 'lib/prism/node.rb', line 10469

def ===(other)
  other.is_a?(IntegerNode) &&
    (flags === other.flags) &&
    (value === other.value)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



10397
10398
10399
# File 'lib/prism/node.rb', line 10397

def accept(visitor)
  visitor.visit_integer_node(self)
end

#binary?Boolean

def binary?: () -> bool

Returns:

  • (Boolean)


10430
10431
10432
# File 'lib/prism/node.rb', line 10430

def binary?
  flags.anybits?(IntegerBaseFlags::BINARY)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



10402
10403
10404
# File 'lib/prism/node.rb', line 10402

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



10412
10413
10414
# File 'lib/prism/node.rb', line 10412

def comment_targets
  [] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



10407
10408
10409
# File 'lib/prism/node.rb', line 10407

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Integer) -> IntegerNode



10417
10418
10419
# File 'lib/prism/node.rb', line 10417

def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value)
  IntegerNode.new(source, node_id, location, flags, value)
end

#decimal?Boolean

def decimal?: () -> bool

Returns:

  • (Boolean)


10435
10436
10437
# File 'lib/prism/node.rb', line 10435

def decimal?
  flags.anybits?(IntegerBaseFlags::DECIMAL)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Integer }



10425
10426
10427
# File 'lib/prism/node.rb', line 10425

def deconstruct_keys(keys)
  { node_id: node_id, location: location, value: value }
end

#hexadecimal?Boolean

def hexadecimal?: () -> bool

Returns:

  • (Boolean)


10445
10446
10447
# File 'lib/prism/node.rb', line 10445

def hexadecimal?
  flags.anybits?(IntegerBaseFlags::HEXADECIMAL)
end

#inspectObject

def inspect -> String



10453
10454
10455
# File 'lib/prism/node.rb', line 10453

def inspect
  InspectVisitor.compose(self)
end

#octal?Boolean

def octal?: () -> bool

Returns:

  • (Boolean)


10440
10441
10442
# File 'lib/prism/node.rb', line 10440

def octal?
  flags.anybits?(IntegerBaseFlags::OCTAL)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



10458
10459
10460
# File 'lib/prism/node.rb', line 10458

def type
  :integer_node
end