Class | JavaClass::Classpath::FolderClasspath |
In: |
lib/javaclass/classpath/folder_classpath.rb
|
Parent: | FileClasspath |
Abstraction of a folder on the CLASSPATH. This is a leaf in the classpath tree.
Author: | Peter Kofler |
Create a classpath with this folder .
# File lib/javaclass/classpath/folder_classpath.rb, line 18 def initialize(folder) super(folder) unless FolderClasspath::valid_location?(folder) raise IOError, "folder #{folder} not found/no folder" end @folder = folder init_classes end
Check if the file is a valid location for a folder classpath.
# File lib/javaclass/classpath/folder_classpath.rb, line 13 def self.valid_location?(file) FileTest.exist?(file) && FileTest.directory?(file) end
Return the number of classes in this folder.
# File lib/javaclass/classpath/folder_classpath.rb, line 51 def count @class_names.size end
Return if classname is included in this folder.
# File lib/javaclass/classpath/folder_classpath.rb, line 37 def includes?(classname) @class_lookup[to_key(classname).file_name] end
Load the binary data of the file name or class name classname from this folder.
# File lib/javaclass/classpath/folder_classpath.rb, line 42 def load_binary(classname) key = to_key(classname) unless includes?(key) raise ClassNotFoundError.new(key, @folder) end File.open(File.join(@folder, key), 'rb') { |io| io.read.freeze } end