Class: RubyLearner::CLI
- Inherits:
-
Thor
- Object
- Thor
- RubyLearner::CLI
- Defined in:
- lib/ruby_learner/ruby_learner.rb
Overview
ruby_learner CLI main class
Instance Method Summary collapse
- #emacs_key ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #install_emacs ⇒ Object
- #restore(*args) ⇒ Object
- #sequential_check(*args) ⇒ Object
- #theme(*args) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(*args) ⇒ CLI
Returns a new instance of CLI.
11 12 13 14 15 16 |
# File 'lib/ruby_learner/ruby_learner.rb', line 11 def initialize(*args) super @workshop_dir = "#{ENV['HOME']}/.ruby_learner/workshop" @gem_dir = File.("../../../", __FILE__) Common.allocate.init_mk_files(gem_dir: @gem_dir, workshop_dir: @workshop_dir) end |
Instance Method Details
#emacs_key ⇒ Object
25 26 27 |
# File 'lib/ruby_learner/ruby_learner.rb', line 25 def emacs_key system("cat #{@gem_dir}/lib/datas/emacs_help.org") end |
#install_emacs ⇒ Object
69 70 71 72 |
# File 'lib/ruby_learner/ruby_learner.rb', line 69 def install_emacs file_path = "#{@gem_dir}/lib/datas/install_emacs.sh" system("sh #{file_path}") end |
#restore(*args) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ruby_learner/ruby_learner.rb', line 55 def restore(*args) if [:refresh] system("rm -rf #{@workshop_dir}/restore/") system("mkdir #{@workshop_dir}/restore") elsif args.empty? == true then system("ls #{@workshop_dir}/restore") print("\n If you want to open a restore_file, you execute 'ruby_learner restore [file_name]'") print("\n If you want to remove all restore_files, you execute 'ruby_learner restore -r'") else system("emacs #{@workshop_dir}/restore/#{args[0]}") end end |
#sequential_check(*args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby_learner/ruby_learner.rb', line 32 def sequential_check(*args) begin sequential_main = SequentialMain.new(@gem_dir, @workshop_dir) if [:drill] sequential_main.drill_contents elsif [:next] final_sec, final_par = sequential_main.get_final_history(@gem_dir) next_sec, next_par = sequential_main.get_next_question(final_sec, final_par) sequential_main.action(next_sec, next_par) else sequential_main.action(args[0], args[1]) end rescue => error puts "Error.message: #{error.}" puts 'sequential_check has 3-modes' puts 'mode-1: $ sequential_check [section:1~11] [part:1~] ,ex) sequential_check 1 3' puts 'mode-2: $ sequential_check -d, check drill contents' puts 'mode-3: $ sequential_check -n, learn next to your last-question' end end |
#theme(*args) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/ruby_learner/ruby_learner.rb', line 75 def theme(*args) args[0].chomp if args[0] == 'black' || args[0] == 'white' Common.allocate.change_theme(color: args[0], gem_dir: @gem_dir) else puts "you can change the theme_color, only black or white." end end |
#version ⇒ Object
20 21 22 |
# File 'lib/ruby_learner/ruby_learner.rb', line 20 def version puts RubyLearner::VERSION end |