Module: Tools

Defined in:
lib/thm.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.guidObject



38
39
40
# File 'lib/thm.rb', line 38

def guid
  guid = Guid.new # Generate GUID
end

.log_errors(file, data) ⇒ Object



42
43
44
45
46
# File 'lib/thm.rb', line 42

def log_errors(file, data)
  File.open("#{file}", 'a') {|n|
    n.puts("#{data}")
  }
end

Instance Method Details

#use_const_defined_unless?(const) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/thm.rb', line 50

def use_const_defined_unless?(const)
  const_down = const.downcase
  if Kernel.const_defined?("#{const}")
    if instance_variable_get("@#{const_down}") == nil
      instance_variable_set("@#{const_down}", Kernel.const_get("#{const}"))
      puts "Config Constant #{const}: #{Kernel.const_get("#{const}")}"
      puts "Instance Variable @#{const_down}: #{instance_variable_get("@#{const_down}")}"
    else
      puts "Param via Getoptlong: Instance Variable #{@const_down}: #{instance_variable_get("@#{const_down}")}"
    end
  else
    raise "No Config option set add #{const} to your config.rb"
  end
end