Class: XfOOrth::FileSource

Inherits:
AbstractSource show all
Defined in:
lib/fOOrth/compiler/source/file_source.rb

Overview

The FileSource class used to extract fOOrth source code from a string.

Instance Attribute Summary

Attributes included from ReadPoint

#read_buffer

Instance Method Summary collapse

Methods inherited from AbstractSource

#eof?, #get, #peek

Methods included from ReadPoint

#eoln?, #read, #reset_read_point

Constructor Details

#initialize(name) ⇒ FileSource

Initialize from a file name.
Parameters:

  • name - The name of the file with the fOOrth source code.



13
14
15
16
17
18
# File 'lib/fOOrth/compiler/source/file_source.rb', line 13

def initialize(name)
  @name      = name
  @file      = File.new(name, "r")
  @read_step = @file.each_line
  super()
end

Instance Method Details

#closeObject

Close the file



21
22
23
24
# File 'lib/fOOrth/compiler/source/file_source.rb', line 21

def close
  @file.close
  super()
end

#file_nameObject

Get the name of the file



32
33
34
# File 'lib/fOOrth/compiler/source/file_source.rb', line 32

def file_name
  File.absolute_path(@name)
end

#source_nameObject

What is the source of this text?



27
28
29
# File 'lib/fOOrth/compiler/source/file_source.rb', line 27

def source_name
  "A file: #{@name}"
end