Class: JavaClass::Classpath::FolderClasspath
- Inherits:
-
Object
- Object
- JavaClass::Classpath::FolderClasspath
- Defined in:
- lib/javaclass/classpath/folder_classpath.rb
Overview
Abstraction of a folder on the CLASSPATH.
- Author
-
Peter Kofler
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#additional_classpath ⇒ Object
Return an empty array.
-
#count ⇒ Object
Return the number of classes in this folder.
-
#includes?(classname) ⇒ Boolean
Return if classname is included in this folder.
-
#initialize(folder) ⇒ FolderClasspath
constructor
Return the list of classnames found in this folder .
-
#jar? ⇒ Boolean
Return false.
-
#load_binary(classname) ⇒ Object
Load the binary data of the file name or class name classname from this jar.
-
#names ⇒ Object
Return the list of class names found in this folder.
- #to_s ⇒ Object
Constructor Details
#initialize(folder) ⇒ FolderClasspath
Return the list of classnames found in this folder .
9 10 11 12 13 14 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 9 def initialize(folder) @folder = folder raise IOError, "folder #{@folder} not found" if !FileTest.exist? @folder raise "#{@folder} is no folder" if !FileTest.directory? @folder @classes = list_classes.collect { |cl| cl.to_javaname } end |
Instance Method Details
#==(other) ⇒ Object
51 52 53 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 51 def ==(other) other.class == FolderClasspath && other.to_s == self.to_s end |
#additional_classpath ⇒ Object
Return an empty array.
22 23 24 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 22 def additional_classpath [] end |
#count ⇒ Object
Return the number of classes in this folder.
43 44 45 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 43 def count @classes.size end |
#includes?(classname) ⇒ Boolean
Return if classname is included in this folder.
32 33 34 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 32 def includes?(classname) @classes.include?(normalize(classname)) end |
#jar? ⇒ Boolean
Return false.
17 18 19 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 17 def jar? false end |
#load_binary(classname) ⇒ Object
Load the binary data of the file name or class name classname from this jar.
37 38 39 40 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 37 def load_binary(classname) raise "class #{classname} not found in #{@folder}" unless includes?(classname) File.open(File.join(@folder, normalize(classname)), 'rb') {|io| io.read } end |
#names ⇒ Object
Return the list of class names found in this folder.
27 28 29 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 27 def names @classes.dup end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/javaclass/classpath/folder_classpath.rb', line 47 def to_s @folder end |