Class: XfOOrth::FileSource
- Inherits:
-
AbstractSource
- Object
- AbstractSource
- XfOOrth::FileSource
- 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
Instance Method Summary collapse
-
#close ⇒ Object
Close the file.
-
#file_name ⇒ Object
Get the name of the file.
-
#initialize(name) ⇒ FileSource
constructor
Initialize from a file name.
-
#source_name ⇒ Object
What is the source of this text?.
Methods inherited from AbstractSource
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
#close ⇒ Object
Close the file
21 22 23 24 |
# File 'lib/fOOrth/compiler/source/file_source.rb', line 21 def close @file.close super() end |
#file_name ⇒ Object
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_name ⇒ Object
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 |