Class: EacRubyUtils::Envs::Executable

Inherits:
Object
  • Object
show all
Includes:
SimpleCache
Defined in:
lib/eac_ruby_utils/envs/executable.rb

Defined Under Namespace

Classes: ProgramNotFoundError

Constant Summary

Constants included from SimpleCache

SimpleCache::UNCACHED_METHOD_PATTERN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SimpleCache

#method_missing, #reset_cache, #respond_to_missing?

Constructor Details

#initialize(env, name, *check_args) ⇒ Executable

Returns a new instance of Executable.


12
13
14
15
16
# File 'lib/eac_ruby_utils/envs/executable.rb', line 12

def initialize(env, name, *check_args)
  @env = env
  @name = name
  @check_args = check_args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EacRubyUtils::SimpleCache

Instance Attribute Details

#check_argsObject (readonly)

Returns the value of attribute check_args


10
11
12
# File 'lib/eac_ruby_utils/envs/executable.rb', line 10

def check_args
  @check_args
end

#envObject (readonly)

Returns the value of attribute env


10
11
12
# File 'lib/eac_ruby_utils/envs/executable.rb', line 10

def env
  @env
end

#nameObject (readonly)

Returns the value of attribute name


10
11
12
# File 'lib/eac_ruby_utils/envs/executable.rb', line 10

def name
  @name
end

Instance Method Details

#command(*command_args) ⇒ Object


34
35
36
37
# File 'lib/eac_ruby_utils/envs/executable.rb', line 34

def command(*command_args)
  validate!
  env.command(name, *command_args)
end

#exist?Boolean

Returns:


18
19
20
# File 'lib/eac_ruby_utils/envs/executable.rb', line 18

def exist?
  exist
end

#validateObject


22
23
24
25
26
# File 'lib/eac_ruby_utils/envs/executable.rb', line 22

def validate
  return nil if exist?

  "Program \"#{name}\" not found in environment #{env}"
end

#validate!Object


28
29
30
31
32
# File 'lib/eac_ruby_utils/envs/executable.rb', line 28

def validate!
  message = validate

  raise ProgramNotFoundError, message if message
end