Class: RubyConfig::Registry
- Inherits:
-
Object
- Object
- RubyConfig::Registry
- Defined in:
- lib/ruby_config/registry.rb
Instance Attribute Summary collapse
-
#ruby_config_path ⇒ Object
readonly
Returns the value of attribute ruby_config_path.
Instance Method Summary collapse
- #add(runtime_const) ⇒ Object
- #exists?(handle) ⇒ Boolean
- #get(handle) ⇒ Object
-
#initialize(ruby_config_path) ⇒ Registry
constructor
A new instance of Registry.
- #list ⇒ Object
- #list_available ⇒ Object
- #list_installed ⇒ Object
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_path ⇒ Object (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
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 |
#list ⇒ Object
17 18 19 |
# File 'lib/ruby_config/registry.rb', line 17 def list @list ||= [] end |
#list_available ⇒ Object
38 39 40 |
# File 'lib/ruby_config/registry.rb', line 38 def list_available list end |
#list_installed ⇒ Object
42 43 44 |
# File 'lib/ruby_config/registry.rb', line 42 def list_installed list.find_all { |item| item.already_installed?} end |