Class: SequentialCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_learner/sequential_check.rb

Direct Known Subclasses

SequentialCheckManual

Instance Method Summary collapse

Constructor Details

#initialize(gem_dir, local_dir) ⇒ SequentialCheck

Returns a new instance of SequentialCheck.



6
7
8
9
10
11
12
# File 'lib/ruby_learner/sequential_check.rb', line 6

def initialize(gem_dir, local_dir)
  @gem_dir = gem_dir
  @local_dir = local_dir
  @workshop_dir = "#{local_dir}/workshop"
  @restore_dir = "#{local_dir}/restore"
  @data_dir = "#{local_dir}/.data"
end

Instance Method Details

#action(sec, par) ⇒ Object

non opt



15
16
17
18
19
20
21
# File 'lib/ruby_learner/sequential_check.rb', line 15

def action(sec, par)
  puts "section_#{sec}/part_#{par}"
  seq_dir = "#{@gem_dir}/contents/questions/sequential_check/section_#{sec}/part_#{par}"
  rubocop_rspec_check = RubocopRspecCheck.new(@local_dir, @gem_dir)
  rubocop_rspec_check.action(mode_dir: seq_dir, is_copy: true)
  write_final_history(sec, par)
end

#change_modeObject

-ch_mode



55
56
57
58
59
60
61
62
63
# File 'lib/ruby_learner/sequential_check.rb', line 55

def change_mode
  mode_txt = "#{@data_dir}/sequential_mode.txt"
  case File.read(mode_txt).chomp
  when 'nomal'
    File.write(mode_txt, 'manual')
  else
    File.write(mode_txt, 'nomal')
  end
end

#drill_contentsObject

-drill



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruby_learner/sequential_check.rb', line 39

def drill_contents
  puts "section  \t part\t contents"
  puts "section_1\t 1~3\t standard_output"
  puts "section_2\t 1~3\t standard_input"
  puts "section_3\t 1~3\t standard_I/O summary"
  puts "section_4\t 1~3\t comparisons & conditionals"
  puts "section_5\t 1~3\t loop_methods"
  puts "section_6\t 1~3\t array & hash & symbol"
  puts "section_7\t 1~3\t function"
  puts "section_8\t 1~3\t class"
  puts "section_9\t 1~3\t regular_expression"
  puts "section_10\t 1~3\t file_operation"
  puts "section_11\t 1~3\t library"
end

#instruct_modesObject



65
66
67
68
69
70
71
72
# File 'lib/ruby_learner/sequential_check.rb', line 65

def instruct_modes
  puts 'sequential_check has 5-modes'
  puts 'mode-1: $ -s [section:1~11] [part:1~], ex) sequential_check 1 3'
  puts 'mode-2: $ -s -d, check drill contents'
  puts 'mode-3: $ -s -n, learn next to your last-question'
  puts 'mode-4: $ -s -l, learn your last-question'
  puts 'mode-5: $ -s -c, change behavior'
end

#last_re_actionObject

-last



31
32
33
34
35
36
# File 'lib/ruby_learner/sequential_check.rb', line 31

def last_re_action
  final_sec, final_par = get_final_history
  puts "section_#{final_sec}/part_#{final_par}"
  rubocop_rspec_check = RubocopRspecCheck.new(@local_dir, @gem_dir)
  rubocop_rspec_check.action(mode_dir: "#{@local_dir}/workshop", is_copy: false)
end

#next_actionObject

-next



24
25
26
27
28
# File 'lib/ruby_learner/sequential_check.rb', line 24

def next_action
  final_sec, final_par = get_final_history
  next_sec, next_par = get_next_question(final_sec, final_par)
  action(next_sec, next_par)
end