Class: Prism::IntegerNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::IntegerNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
Represents an integer number literal.
1
^
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
The value of the integer literal as a number.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#binary? ⇒ Boolean
def binary?: () -> bool.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#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.
-
#decimal? ⇒ Boolean
def decimal?: () -> bool.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Integer }.
-
#hexadecimal? ⇒ Boolean
def hexadecimal?: () -> bool.
-
#initialize(source, node_id, location, flags, value) ⇒ IntegerNode
constructor
Initialize a new IntegerNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#octal? ⇒ Boolean
def octal?: () -> bool.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, value) ⇒ IntegerNode
Initialize a new IntegerNode node.
9224 9225 9226 9227 9228 9229 9230 |
# File 'lib/prism/node.rb', line 9224 def initialize(source, node_id, location, flags, value) @source = source @node_id = node_id @location = location @flags = flags @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
The value of the integer literal as a number.
9286 9287 9288 |
# File 'lib/prism/node.rb', line 9286 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
9299 9300 9301 |
# File 'lib/prism/node.rb', line 9299 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.
9305 9306 9307 9308 9309 |
# File 'lib/prism/node.rb', line 9305 def ===(other) other.is_a?(IntegerNode) && (flags === other.flags) && (value === other.value) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
9233 9234 9235 |
# File 'lib/prism/node.rb', line 9233 def accept(visitor) visitor.visit_integer_node(self) end |
#binary? ⇒ Boolean
def binary?: () -> bool
9266 9267 9268 |
# File 'lib/prism/node.rb', line 9266 def binary? flags.anybits?(IntegerBaseFlags::BINARY) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
9238 9239 9240 |
# File 'lib/prism/node.rb', line 9238 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
9248 9249 9250 |
# File 'lib/prism/node.rb', line 9248 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
9243 9244 9245 |
# File 'lib/prism/node.rb', line 9243 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
9253 9254 9255 |
# File 'lib/prism/node.rb', line 9253 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
9271 9272 9273 |
# File 'lib/prism/node.rb', line 9271 def decimal? flags.anybits?(IntegerBaseFlags::DECIMAL) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Integer }
9261 9262 9263 |
# File 'lib/prism/node.rb', line 9261 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value } end |
#hexadecimal? ⇒ Boolean
def hexadecimal?: () -> bool
9281 9282 9283 |
# File 'lib/prism/node.rb', line 9281 def hexadecimal? flags.anybits?(IntegerBaseFlags::HEXADECIMAL) end |
#inspect ⇒ Object
def inspect -> String
9289 9290 9291 |
# File 'lib/prism/node.rb', line 9289 def inspect InspectVisitor.compose(self) end |
#octal? ⇒ Boolean
def octal?: () -> bool
9276 9277 9278 |
# File 'lib/prism/node.rb', line 9276 def octal? flags.anybits?(IntegerBaseFlags::OCTAL) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
9294 9295 9296 |
# File 'lib/prism/node.rb', line 9294 def type :integer_node end |