Class: Pik::Use

Inherits:
Command show all
Includes:
ScriptFileEditor
Defined in:
lib/pik/commands/use_command.rb

Instance Attribute Summary collapse

Attributes included from ScriptFileEditor

#script

Attributes inherited from Command

#config, #debug, #options, #output, #version

Instance Method Summary collapse

Methods included from ScriptFileEditor

#echo_ruby_version, #initialize, #set, #switch_gem_home_to, #switch_path_to

Methods inherited from Command

#actual_gem_home, #add_sigint_handler, aka, choose_from, #close, cmd_name, #cmd_name, #create, #current_gem_bin_path, #current_version?, #default_gem_home, #delete_old_pik_script, description, #editors, #find_config_from_path, #gem_path, #get_version, hl, inherited, #initialize, it, names, #parse_options, #pik_version, #sh, summary

Instance Attribute Details

#gem_homeObject

Returns the value of attribute gem_home.



10
11
12
# File 'lib/pik/commands/use_command.rb', line 10

def gem_home
  @gem_home
end

#globalObject

Returns the value of attribute global.



9
10
11
# File 'lib/pik/commands/use_command.rb', line 9

def global
  @global
end

#verboseObject

Returns the value of attribute verbose.



11
12
13
# File 'lib/pik/commands/use_command.rb', line 11

def verbose
  @verbose
end

Instance Method Details

#command_optionsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/pik/commands/use_command.rb', line 20

def command_options
  super
  
  options.on("--verbose", "-v",
     "Display verbose output"
     ) do |value|
    @verbose = true
  end

  sep =<<SEP
  Examples:

C:\\>pik sw 186 mingw
Using ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]

C:\\>pik switch 191 p1
Using ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]

C:\\>pik use 186 mswin
Using ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]

C:\\>pik 191 p2
Using ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
SEP
  options.separator sep
end

#executeObject



13
14
15
16
17
18
# File 'lib/pik/commands/use_command.rb', line 13

def execute
  abort('Nothing matches:') unless new_ver = self.class.choose_from(@args, @config)
  switch_path_to(@config[new_ver])
  switch_gem_home_to(@config[new_ver][:gem_home])
  echo_ruby_version(@config[new_ver][:path]) if verbose
end