Class: GetVersion::Executable

Inherits:
Object
  • Object
show all
Defined in:
lib/getversion/executable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, namespace, &block) ⇒ Executable

Returns a new instance of Executable.



10
11
12
13
14
# File 'lib/getversion/executable.rb', line 10

def initialize(name, namespace, &block)
  @name = name
  @namespace = namespace
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



8
9
10
# File 'lib/getversion/executable.rb', line 8

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/getversion/executable.rb', line 8

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



8
9
10
# File 'lib/getversion/executable.rb', line 8

def namespace
  @namespace
end

Class Method Details

.version(name, &block) ⇒ Object



27
28
29
# File 'lib/getversion/executable.rb', line 27

def self.version(name, &block)
  Executable.new(name, nil, &block).version
end

Instance Method Details

#pathObject



21
22
23
24
25
# File 'lib/getversion/executable.rb', line 21

def path
  dir = PathFinder.find_path @name
  dir = nil if dir == '.'
  dir ? Path.new(dir, name).evaluated_path : @name
end

#versionObject



16
17
18
19
# File 'lib/getversion/executable.rb', line 16

def version
  c = ExecutionContext.new path
  c.execute &@block if @block
end