Class: Doubleshot::Compiler::Classpath

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/doubleshot/compiler/classpath.rb

Instance Method Summary collapse

Constructor Details

#initializeClasspath

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).expand_path

  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

#eachObject



37
38
39
# File 'lib/doubleshot/compiler/classpath.rb', line 37

def each
  @set.each { |entry| yield entry }
end

#empty?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/doubleshot/compiler/classpath.rb', line 33

def empty?
 @set.empty?
end

#sizeObject Also known as: length



28
29
30
# File 'lib/doubleshot/compiler/classpath.rb', line 28

def size
  @set.size
end

#to_sObject



41
42
43
# File 'lib/doubleshot/compiler/classpath.rb', line 41

def to_s
  "CLASSPATH: #{@set.entries.sort.join(", ")}"
end