Class: Gamefic::Source::File

Inherits:
Base
  • Object
show all
Defined in:
lib/gamefic/source/file.rb

Constant Summary collapse

@@extensions =
['.plot.rb', '.plot', '.rb']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*directories) ⇒ File

Returns a new instance of File.



7
8
9
# File 'lib/gamefic/source/file.rb', line 7

def initialize(*directories)
  @directories = directories || []
end

Instance Attribute Details

#directoriesObject (readonly)

Returns the value of attribute directories.



5
6
7
# File 'lib/gamefic/source/file.rb', line 5

def directories
  @directories
end

#main_dirObject

Returns the value of attribute main_dir.



6
7
8
# File 'lib/gamefic/source/file.rb', line 6

def main_dir
  @main_dir
end

Instance Method Details

#export(path) ⇒ Object

Raises:

  • (LoadError)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gamefic/source/file.rb', line 10

def export path
  @directories.each { |directory|
    @@extensions.each { |ext|
      abs_file = File.join(directory, path + ext)
      if File.file?(abs_file)
        return Script::File.new(abs_file, path)
      end
    }
  }
  raise LoadError.new("cannot load script -- #{path}")
end