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.
-
#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 }.
-
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator.
-
#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.
11146 11147 11148 11149 11150 11151 11152 |
# File 'lib/prism/node.rb', line 11146 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.
11214 11215 11216 |
# File 'lib/prism/node.rb', line 11214 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See Node::type.
11227 11228 11229 |
# File 'lib/prism/node.rb', line 11227 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.
11233 11234 11235 11236 11237 |
# File 'lib/prism/node.rb', line 11233 def ===(other) other.is_a?(IntegerNode) && (flags === other.flags) && (value === other.value) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
11155 11156 11157 |
# File 'lib/prism/node.rb', line 11155 def accept(visitor) visitor.visit_integer_node(self) end |
#binary? ⇒ Boolean
def binary?: () -> bool
11194 11195 11196 |
# File 'lib/prism/node.rb', line 11194 def binary? flags.anybits?(IntegerBaseFlags::BINARY) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
11160 11161 11162 |
# File 'lib/prism/node.rb', line 11160 def child_nodes [] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
11176 11177 11178 |
# File 'lib/prism/node.rb', line 11176 def comment_targets [] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
11171 11172 11173 |
# File 'lib/prism/node.rb', line 11171 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
11181 11182 11183 |
# File 'lib/prism/node.rb', line 11181 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
11199 11200 11201 |
# File 'lib/prism/node.rb', line 11199 def decimal? flags.anybits?(IntegerBaseFlags::DECIMAL) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, value: Integer }
11189 11190 11191 |
# File 'lib/prism/node.rb', line 11189 def deconstruct_keys(keys) { node_id: node_id, location: location, value: value } end |
#each_child_node ⇒ Object
def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator
11165 11166 11167 11168 |
# File 'lib/prism/node.rb', line 11165 def each_child_node return to_enum(:each_child_node) unless block_given? end |
#hexadecimal? ⇒ Boolean
def hexadecimal?: () -> bool
11209 11210 11211 |
# File 'lib/prism/node.rb', line 11209 def hexadecimal? flags.anybits?(IntegerBaseFlags::HEXADECIMAL) end |
#inspect ⇒ Object
def inspect -> String
11217 11218 11219 |
# File 'lib/prism/node.rb', line 11217 def inspect InspectVisitor.compose(self) end |
#octal? ⇒ Boolean
def octal?: () -> bool
11204 11205 11206 |
# File 'lib/prism/node.rb', line 11204 def octal? flags.anybits?(IntegerBaseFlags::OCTAL) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
11222 11223 11224 |
# File 'lib/prism/node.rb', line 11222 def type :integer_node end |