Class: RubyConfig::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_config/registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ruby_config_path) ⇒ Registry

Returns a new instance of Registry.



12
13
14
15
# File 'lib/ruby_config/registry.rb', line 12

def initialize(ruby_config_path)
  @ruby_config_path = ruby_config_path
  load_available_runtimes.each { |runtime| add(runtime) }
end

Instance Attribute Details

#ruby_config_pathObject (readonly)

Returns the value of attribute ruby_config_path.



10
11
12
# File 'lib/ruby_config/registry.rb', line 10

def ruby_config_path
  @ruby_config_path
end

Instance Method Details

#add(runtime_const) ⇒ Object



21
22
23
# File 'lib/ruby_config/registry.rb', line 21

def add(runtime_const)
  list << runtime_const.new(runtime_install_path, tmp_path)
end

#exists?(handle) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ruby_config/registry.rb', line 25

def exists?(handle)
  !!get(handle)
end

#get(handle) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/ruby_config/registry.rb', line 29

def get(handle)
  handle_int = handle.to_i # returns 0 if no fixnum
  if handle_int > 0 && handle_int << list.size
    list.values_at(handle_int-1).first
  else
    list.find { |item| item.handle == handle  }
  end
end

#listObject



17
18
19
# File 'lib/ruby_config/registry.rb', line 17

def list
  @list ||= []
end

#list_availableObject



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

def list_available
  list
end

#list_installedObject



42
43
44
# File 'lib/ruby_config/registry.rb', line 42

def list_installed
  list.find_all { |item| item.already_installed?}
end