Class: Sevgi::Executor::Source Private

Inherits:
Data
  • Object
show all
Defined in:
lib/sevgi/executor/source.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Describes Ruby source evaluated by the Sevgi executor.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string:, file: nil, line: nil) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a source object.

Parameters:

  • string (String)

    Ruby source string

  • file (String, nil) (defaults to: nil)

    source file name for diagnostics

  • line (Integer, nil) (defaults to: nil)

    starting source line for diagnostics



27
# File 'lib/sevgi/executor/source.rb', line 27

def initialize(string:, file: nil, line: nil) = super(string:, file: file || "sevgi", line: line || 1)

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



7
8
9
# File 'lib/sevgi/executor/source.rb', line 7

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



7
8
9
# File 'lib/sevgi/executor/source.rb', line 7

def line
  @line
end

#stringObject (readonly)

Returns the value of attribute string

Returns:

  • (Object)

    the current value of string



7
8
9
# File 'lib/sevgi/executor/source.rb', line 7

def string
  @string
end

Class Method Details

.call(string:, file: nil, line: nil) ⇒ Sevgi::Executor::Source

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a source object.

Parameters:

  • string (String)

    Ruby source string

  • file (String, nil) (defaults to: nil)

    source file name for diagnostics

  • line (Integer, nil) (defaults to: nil)

    starting source line for diagnostics

Returns:



14
# File 'lib/sevgi/executor/source.rb', line 14

def self.call(...) = new(...)

.load(file) ⇒ Sevgi::Executor::Source

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Builds a source object from a file.

Parameters:

  • file (String)

    source file to read

Returns:

Raises:

  • (Errno::ENOENT)

    when the file cannot be read



20
# File 'lib/sevgi/executor/source.rb', line 20

def self.load(file) = new(string: ::File.read(file), file: file, line: 1)

Instance Method Details

#keyString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the stack key used for this source.

Returns:

  • (String)

    source file name



31
# File 'lib/sevgi/executor/source.rb', line 31

def key = file