Class: Doubleshot::Compiler::Classpath
- Includes:
- Enumerable
- Defined in:
- lib/doubleshot/compiler/classpath.rb
Instance Method Summary collapse
- #add(path) ⇒ Object (also: #<<)
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Classpath
constructor
A new instance of Classpath.
- #size ⇒ Object (also: #length)
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Classpath
Returns a new instance of Classpath.
9 10 11 |
# File 'lib/doubleshot/compiler/classpath.rb', line 9 def initialize @set = Set.new end |
Instance Method Details
#add(path) ⇒ Object Also known as: <<
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/doubleshot/compiler/classpath.rb', line 13 def add(path) path = Pathname(path.to_s). if path.directory? @set << path elsif path.file? @set << path.dirname else raise ArgumentError.new("+path+ must be a file or directory with read permission: #{path}") end self end |
#each ⇒ Object
37 38 39 |
# File 'lib/doubleshot/compiler/classpath.rb', line 37 def each @set.each { |entry| yield entry } end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/doubleshot/compiler/classpath.rb', line 33 def empty? @set.empty? end |
#size ⇒ Object Also known as: length
28 29 30 |
# File 'lib/doubleshot/compiler/classpath.rb', line 28 def size @set.size end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/doubleshot/compiler/classpath.rb', line 41 def to_s "CLASSPATH: #{@set.entries.sort.join(", ")}" end |