Class: Prism::SourceLineNode

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

Overview

Represents the use of the __LINE__ keyword.

__LINE__
^^^^^^^^

Explore code sample

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags) ⇒ SourceLineNode

Initialize a new SourceLineNode node.

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

Parameters:

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


30574
30575
30576
30577
30578
30579
# File 'lib/prism/node.rb', line 30574

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

Class Method Details

.type ⇒ :source_line_node

See Node.type.

: () -> :source_line_node

Returns:

  • (:source_line_node)


30656
30657
30658
# File 'lib/prism/node.rb', line 30656

def self.type
  :source_line_node
end

Instance Method Details

#===(other) ⇒ boolish

: (untyped other) -> boolish

Parameters:

  • other (Object)

Returns:

  • (boolish)


30672
30673
30674
# File 'lib/prism/node.rb', line 30672

def ===(other) # :nodoc:
  other.is_a?(SourceLineNode)
end

#accept(visitor) ⇒ Object

See Node.accept.

: (_Visitor visitor) -> untyped

Parameters:

Returns:

  • (Object)


30595
30596
30597
# File 'lib/prism/node.rb', line 30595

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

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

See Node.child_nodes.

: () -> Array

Returns:

  • (Array[node?])


30602
30603
30604
# File 'lib/prism/node.rb', line 30602

def child_nodes
  []
end

#compact_child_nodes ⇒ Array[node]

See Node.compact_child_nodes.

: () -> Array

Returns:

  • (Array[node])


30618
30619
30620
# File 'lib/prism/node.rb', line 30618

def compact_child_nodes
  []
end

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

:call-seq:

copy(**fields) -> SourceLineNode

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

: (?node_id: Integer, ?location: Location, ?flags: Integer, ) -> SourceLineNode

Parameters:

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

Returns:



30628
30629
30630
# File 'lib/prism/node.rb', line 30628

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

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

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

Parameters:

  • keys (Array[Symbol], nil)

Returns:

  • (Hash[Symbol, untyped])


30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
# File 'lib/prism/node.rb', line 30635

def deconstruct_keys(keys) # :nodoc:
  (keys || i[node_id location]).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
    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)


30610
30611
30612
30613
# File 'lib/prism/node.rb', line 30610

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

end

#inspect ⇒ String

: () -> String

Returns:

  • (String)


30661
30662
30663
# File 'lib/prism/node.rb', line 30661

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

#type ⇒ :source_line_node

See Node#type.

: () -> :source_line_node

Returns:

  • (:source_line_node)


30649
30650
30651
# File 'lib/prism/node.rb', line 30649

def type
  :source_line_node
end