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.



10527
10528
10529
10530
10531
10532
10533
# File 'lib/prism/node.rb', line 10527

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.



10589
10590
10591
# File 'lib/prism/node.rb', line 10589

def value
  @value
end

Class Method Details

.typeObject

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



10602
10603
10604
# File 'lib/prism/node.rb', line 10602

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.



10608
10609
10610
10611
10612
# File 'lib/prism/node.rb', line 10608

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



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

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

#binary?Boolean

def binary?: () -> bool

Returns:

  • (Boolean)


10569
10570
10571
# File 'lib/prism/node.rb', line 10569

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



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

def child_nodes
  []
end

#comment_targetsObject

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



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

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



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

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



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

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)


10574
10575
10576
# File 'lib/prism/node.rb', line 10574

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

#deconstruct_keys(keys) ⇒ Object

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



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

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

#hexadecimal?Boolean

def hexadecimal?: () -> bool

Returns:

  • (Boolean)


10584
10585
10586
# File 'lib/prism/node.rb', line 10584

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

#inspectObject

def inspect -> String



10592
10593
10594
# File 'lib/prism/node.rb', line 10592

def inspect
  InspectVisitor.compose(self)
end

#octal?Boolean

def octal?: () -> bool

Returns:

  • (Boolean)


10579
10580
10581
# File 'lib/prism/node.rb', line 10579

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

#typeObject

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



10597
10598
10599
# File 'lib/prism/node.rb', line 10597

def type
  :integer_node
end