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.



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

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

Class Method Details

.version(name, &block) ⇒ Object



19
20
21
# File 'lib/getversion/executable.rb', line 19

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

Instance Method Details

#path(dir = nil) ⇒ Object



23
24
25
26
27
28
# File 'lib/getversion/executable.rb', line 23

def path(dir=nil)
  dir ||= ExecutablePathFinder.find_dir @name
  dir = nil if dir == '.'
  return @name unless dir
  File.join dir, @name
end

#version(dir = nil) ⇒ Object



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

def version(dir=nil)
  ExecutionContext.execute path(dir), &@block
end