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.



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

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

#path_with_task_name(task_name) ⇒ Object

Path for the scope + the named path.



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

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.



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

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