Class: Rake::Scope

Inherits:
LinkedList show all
Defined in:
lib/rake/scope.rb

Overview

:nodoc: all

Defined Under Namespace

Classes: EmptyScope

Constant Summary collapse

EMPTY =

Singleton null object for an empty scope.

EmptyScope.new

Instance Attribute Summary

Attributes inherited from LinkedList

#head, #tail

Instance Method Summary collapse

Methods inherited from LinkedList

#==, #conj, cons, #each, empty, #empty?, #inspect, make, #to_s

Instance Method Details

#pathObject

Path for the scope.



5
6
7
# File 'lib/rake/scope.rb', line 5

def path
  map(&:to_s).reverse.join(":")
end

#path_with_task_name(task_name) ⇒ Object

Path for the scope + the named path.



10
11
12
# File 'lib/rake/scope.rb', line 10

def path_with_task_name(task_name)
  "#{path}:#{task_name}"
end

#trim(n) ⇒ Object

Trim n innermost scope levels from the scope. In no case will this trim beyond the toplevel scope.



16
17
18
19
20
21
22
23
# File 'lib/rake/scope.rb', line 16

def trim(n)
  result = self
  while n > 0 && ! result.empty?
    result = result.tail
    n -= 1
  end
  result
end