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.



10490
10491
10492
10493
10494
10495
10496
# File 'lib/prism/node.rb', line 10490

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.



10552
10553
10554
# File 'lib/prism/node.rb', line 10552

def value
  @value
end

Class Method Details

.typeObject

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



10565
10566
10567
# File 'lib/prism/node.rb', line 10565

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.



10571
10572
10573
10574
10575
# File 'lib/prism/node.rb', line 10571

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



10499
10500
10501
# File 'lib/prism/node.rb', line 10499

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

#binary?Boolean

def binary?: () -> bool

Returns:

  • (Boolean)


10532
10533
10534
# File 'lib/prism/node.rb', line 10532

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



10504
10505
10506
# File 'lib/prism/node.rb', line 10504

def child_nodes
  []
end

#comment_targetsObject

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



10514
10515
10516
# File 'lib/prism/node.rb', line 10514

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



10509
10510
10511
# File 'lib/prism/node.rb', line 10509

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



10519
10520
10521
# File 'lib/prism/node.rb', line 10519

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)


10537
10538
10539
# File 'lib/prism/node.rb', line 10537

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

#deconstruct_keys(keys) ⇒ Object

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



10527
10528
10529
# File 'lib/prism/node.rb', line 10527

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

#hexadecimal?Boolean

def hexadecimal?: () -> bool

Returns:

  • (Boolean)


10547
10548
10549
# File 'lib/prism/node.rb', line 10547

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

#inspectObject

def inspect -> String



10555
10556
10557
# File 'lib/prism/node.rb', line 10555

def inspect
  InspectVisitor.compose(self)
end

#octal?Boolean

def octal?: () -> bool

Returns:

  • (Boolean)


10542
10543
10544
# File 'lib/prism/node.rb', line 10542

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

#typeObject

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



10560
10561
10562
# File 'lib/prism/node.rb', line 10560

def type
  :integer_node
end