Class: Prism::FloatNode

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

Overview

Represents a floating point number literal.

1.0
^^^

Explore code sample

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, value) ⇒ FloatNode

Initialize a new FloatNode node.

: (Source source, Integer node_id, Location location, Integer flags, Float value) -> void

Parameters:

  • source (Source)
  • node_id (Integer)
  • location (Location)
  • flags (Integer)
  • value (Float)


13030
13031
13032
13033
13034
13035
13036
# File 'lib/prism/node.rb', line 13030

def initialize(source, node_id, location, flags, value)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @value = value
end

Class Method Details

.type ⇒ :float_node

See Node.type.

: () -> :float_node

Returns:

  • (:float_node)


13114
13115
13116
# File 'lib/prism/node.rb', line 13114

def self.type
  :float_node
end

Instance Method Details

#===(other) ⇒ boolish

: (untyped other) -> boolish

Parameters:

  • other (Object)

Returns:

  • (boolish)


13140
13141
13142
13143
# File 'lib/prism/node.rb', line 13140

def ===(other) # :nodoc:
  other.is_a?(FloatNode) &&
    (value === other.value)
end

#accept(visitor) ⇒ Object

See Node.accept.

: (_Visitor visitor) -> untyped

Parameters:

Returns:

  • (Object)


13052
13053
13054
# File 'lib/prism/node.rb', line 13052

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

#child_nodes ⇒ Array[node?] Also known as: deconstruct

See Node.child_nodes.

: () -> Array

Returns:

  • (Array[node?])


13059
13060
13061
# File 'lib/prism/node.rb', line 13059

def child_nodes
  []
end

#compact_child_nodes ⇒ Array[node]

See Node.compact_child_nodes.

: () -> Array

Returns:

  • (Array[node])


13075
13076
13077
# File 'lib/prism/node.rb', line 13075

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value) ⇒ FloatNode

:call-seq:

copy(**fields) -> FloatNode

Creates a copy of self with the given fields, using self as the template.

: (?node_id: Integer, ?location: Location, ?flags: Integer, ?value: Float) -> FloatNode

Parameters:

  • node_id: (Integer) (defaults to: self.node_id)
  • location: (Location) (defaults to: self.location)
  • flags: (Integer) (defaults to: self.flags)
  • value: (Float) (defaults to: self.value)

Returns:



13085
13086
13087
# File 'lib/prism/node.rb', line 13085

def copy(node_id: self.node_id, location: self.location, flags: self.flags, value: self.value)
  FloatNode.new(source, node_id, location, flags, value)
end

#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]

: (Array? keys) -> Hash[Symbol, untyped]

Parameters:

  • keys (Array[Symbol], nil)

Returns:

  • (Hash[Symbol, untyped])


13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
# File 'lib/prism/node.rb', line 13092

def deconstruct_keys(keys) # :nodoc:
  (keys || %i[node_id location value]).each_with_object(
    {} #: Hash[Symbol, untyped]
  ) do |key, deconstructed|
    case key
    when :node_id                 then deconstructed[:node_id] = self.node_id
    when :location                then deconstructed[:location] = self.location
    when :value                   then deconstructed[:value] = self.value
    end
  end
end

#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void

See Node.each_child_node.

: () -> Enumerator[node, void] : () { (node) -> void } -> void

Overloads:

  • #each_child_node ⇒ Enumerator[node, void]

    Returns:

    • (Enumerator[node, void])
  • #each_child_node ⇒ void

    This method returns an undefined value.

Yields:

Yield Parameters:

  • arg0 (node)

Yield Returns:

  • (void)


13067
13068
13069
13070
# File 'lib/prism/node.rb', line 13067

def each_child_node(&blk)
  return to_enum(:each_child_node) unless block_given?

end

#inspect ⇒ String

: () -> String

Returns:

  • (String)


13119
13120
13121
# File 'lib/prism/node.rb', line 13119

def inspect # :nodoc:
  InspectVisitor.compose(self)
end

#type ⇒ :float_node

See Node#type.

: () -> :float_node

Returns:

  • (:float_node)


13107
13108
13109
# File 'lib/prism/node.rb', line 13107

def type
  :float_node
end

#value ⇒ Float

:call-seq:

value -> Float

The value of the floating point number as a Float.

: () -> Float

Returns:

  • (Float)


13131
13132
13133
# File 'lib/prism/node.rb', line 13131

def value
  @value
end