Class: IRuby::Command
- Inherits:
-
Object
- Object
- IRuby::Command
- Defined in:
- lib/iruby/command.rb
Instance Attribute Summary collapse
-
#ipython_dir ⇒ Object
readonly
Returns the value of attribute ipython_dir.
-
#kernel_dir ⇒ Object
readonly
Returns the value of attribute kernel_dir.
-
#kernel_file ⇒ Object
readonly
Returns the value of attribute kernel_file.
Instance Method Summary collapse
-
#initialize(args) ⇒ Command
constructor
A new instance of Command.
- #ipython_kernel_dir ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Command
Returns a new instance of Command.
8 9 10 11 12 13 14 15 |
# File 'lib/iruby/command.rb', line 8 def initialize(args) @args = args @ipython_dir = File.("~/.ipython") @kernel_dir = resolve_kernelspec_dir.freeze @kernel_file = File.join(@kernel_dir, 'kernel.json').freeze @iruby_path = File. $0 end |
Instance Attribute Details
#ipython_dir ⇒ Object (readonly)
Returns the value of attribute ipython_dir.
17 18 19 |
# File 'lib/iruby/command.rb', line 17 def ipython_dir @ipython_dir end |
#kernel_dir ⇒ Object (readonly)
Returns the value of attribute kernel_dir.
17 18 19 |
# File 'lib/iruby/command.rb', line 17 def kernel_dir @kernel_dir end |
#kernel_file ⇒ Object (readonly)
Returns the value of attribute kernel_file.
17 18 19 |
# File 'lib/iruby/command.rb', line 17 def kernel_file @kernel_file end |
Instance Method Details
#ipython_kernel_dir ⇒ Object
19 20 21 |
# File 'lib/iruby/command.rb', line 19 def ipython_kernel_dir File.join(File.(@ipython_dir), 'kernels', 'ruby') end |
#run ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/iruby/command.rb', line 23 def run case @args.first when 'version', '-v', '--version' require 'iruby/version' puts "IRuby #{IRuby::VERSION}, Ruby #{RUBY_VERSION}" when 'help', '-h', '--help' print_help when 'register' force_p = @args.include?('--force') if registered_iruby_path && !force_p STDERR.puts "#{@kernel_file} already exists!\nUse --force to force a register." exit 1 end register_kernel(force_p) when 'unregister' unregister_kernel when 'kernel' run_kernel else run_ipython end end |