class Prism::SourceFileNode - Documentation for Ruby 4.1
Description: class Prism::SourceFileNode: Represents the use of the `__FILE__` keyword.
Keywords: ruby,class,Prism::SourceFileNode

🔍

No recent searches

# class Prism::SourceFileNode

Represents the use of the `__FILE__` keyword.

    __FILE__
    ^^^^^^^^

### Public Class Methods

new (source, node_id, location, flags, filepath)
Source

    # File lib/prism/node.rb, line 28415
    def initialize(source, node_id, location, flags, filepath)
      @source = source
      @node_id = node_id
      @location = location
      @flags = flags
      @filepath = filepath
    end

Initialize a new `SourceFileNode` node.

### Public Instance Methods

filepath → String
Source

    # File lib/prism/node.rb, line 28547
    def filepath
      @filepath
    end

Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism.parse*` APIs.

## Flags

### Public Instance Methods

forced_binary_encoding? ()
Source

    # File lib/prism/node.rb, line 28521
    def forced_binary_encoding?
      flags.anybits?(StringFlags::FORCED_BINARY_ENCODING)
    end

internal bytes forced the encoding to binary

forced_utf8_encoding? ()
Source

    # File lib/prism/node.rb, line 28513
    def forced_utf8_encoding?
      flags.anybits?(StringFlags::FORCED_UTF8_ENCODING)
    end

internal bytes forced the encoding to UTF-8

frozen? ()
Source

    # File lib/prism/node.rb, line 28529
    def frozen?
      flags.anybits?(StringFlags::FROZEN)
    end

frozen by virtue of a `frozen_string_literal: true` comment or `--enable-frozen-string-literal`

mutable? ()
Source

    # File lib/prism/node.rb, line 28537
    def mutable?
      flags.anybits?(StringFlags::MUTABLE)
    end

mutable by virtue of a `frozen_string_literal: false` comment or `--disable-frozen-string-literal`

## Node Interface

These methods are present on all subclasses of `Node`. Read the node interface docs for more information.

### Public Class Methods

type ()
Source

    # File lib/prism/node.rb, line 28498
    def self.type
      :source_file_node
    end

See `Node.type`.

### Public Instance Methods

accept (visitor)
Source

    # File lib/prism/node.rb, line 28437
    def accept(visitor)
      visitor.visit_source_file_node(self)
    end

See `Node.accept`.

child_nodes ()
Source

    # File lib/prism/node.rb, line 28444
    def child_nodes
      []
    end

See `Node.child_nodes`.

Also aliased as: deconstruct
comment_targets ()
Source

    # File lib/prism/node.rb, line 28467
    def comment_targets
      [] #: Array[Prism::node | Location]
    end

See `Node.comment_targets`.

compact_child_nodes ()
Source

    # File lib/prism/node.rb, line 28460
    def compact_child_nodes
      []
    end

See `Node.compact_child_nodes`.

copy(**fields) → SourceFileNode
Source

    # File lib/prism/node.rb, line 28477
    def copy(node_id: self.node_id, location: self.location, flags: self.flags, filepath: self.filepath)
      SourceFileNode.new(source, node_id, location, flags, filepath)
    end

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

deconstruct ()
Alias for: child_nodes
each_child_node (&blk)
Source

    # File lib/prism/node.rb, line 28452
    def each_child_node(&blk)
      return to_enum(:each_child_node) unless block_given?

    end

See `Node.each_child_node`.

type ()
Source

    # File lib/prism/node.rb, line 28491
    def type
      :source_file_node
    end

See `Node#type`.

## Repository

Methods related to `Relocation`.

## Slicing