Class: Prism::IntegerNode

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

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.

[View source]

9261
9262
9263
9264
9265
9266
9267
# File 'lib/prism/node.rb', line 9261

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.


9323
9324
9325
# File 'lib/prism/node.rb', line 9323

def value
  @value
end

Class Method Details

.typeObject

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

[View source]

9336
9337
9338
# File 'lib/prism/node.rb', line 9336

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.

[View source]

9342
9343
9344
9345
9346
# File 'lib/prism/node.rb', line 9342

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

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void

[View source]

9270
9271
9272
# File 'lib/prism/node.rb', line 9270

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

#binary?Boolean

def binary?: () -> bool

Returns:

  • (Boolean)
[View source]

9303
9304
9305
# File 'lib/prism/node.rb', line 9303

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

#child_nodesObject Also known as: deconstruct

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

[View source]

9275
9276
9277
# File 'lib/prism/node.rb', line 9275

def child_nodes
  []
end

#comment_targetsObject

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

[View source]

9285
9286
9287
# File 'lib/prism/node.rb', line 9285

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array

[View source]

9280
9281
9282
# File 'lib/prism/node.rb', line 9280

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

[View source]

9290
9291
9292
# File 'lib/prism/node.rb', line 9290

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)
[View source]

9308
9309
9310
# File 'lib/prism/node.rb', line 9308

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

#deconstruct_keys(keys) ⇒ Object

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

[View source]

9298
9299
9300
# File 'lib/prism/node.rb', line 9298

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

#hexadecimal?Boolean

def hexadecimal?: () -> bool

Returns:

  • (Boolean)
[View source]

9318
9319
9320
# File 'lib/prism/node.rb', line 9318

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

#inspectObject

def inspect -> String

[View source]

9326
9327
9328
# File 'lib/prism/node.rb', line 9326

def inspect
  InspectVisitor.compose(self)
end

#octal?Boolean

def octal?: () -> bool

Returns:

  • (Boolean)
[View source]

9313
9314
9315
# File 'lib/prism/node.rb', line 9313

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

#typeObject

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

[View source]

9331
9332
9333
# File 'lib/prism/node.rb', line 9331

def type
  :integer_node
end