Class: XfOOrth::StringSource

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

Overview

The StringSource 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

#close, #eof?, #get, #peek

Methods included from ReadPoint

#eoln?, #read, #reset_read_point

Constructor Details

#initialize(string) ⇒ StringSource

Initialize from a string.
Parameters:

  • string - A string of fOOrth source code.



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

def initialize(string)
  @string_list = string.split("\n")
  @read_step   = @string_list.each
  super()
end

Instance Method Details

#file_nameObject

A string source has no file name to return.



25
26
27
# File 'lib/fOOrth/compiler/source/string_source.rb', line 25

def file_name
  nil
end

#source_nameObject

What is the source of this text?



20
21
22
# File 'lib/fOOrth/compiler/source/string_source.rb', line 20

def source_name
  "A string."
end