Class: DEBUGGER__::Console
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/debug/console.rb |
Constant Summary
-
FH =
# File 'lib/debug/console.rb', line 165"# Today's OMIKUJI: "
Class Method Summary
- .new ⇒ Console constructor
Instance Method Summary
Constructor Details
.new ⇒ Console
# File 'lib/debug/console.rb', line 176
def initialize @init_history_lines = nil end
Instance Method Details
#deactivate
[ GitHub ]# File 'lib/debug/console.rb', line 186
def deactivate if history && @init_history_lines added_records = history.to_a[@init_history_lines .. -1] path = history_file max = CONFIG[:save_history] if !added_records.empty? && !path.empty? orig_records = read_history_file open(history_file, 'w'){|f| (orig_records + added_records).last(max).each{|line| if !line.start_with?(FH) && !line.strip.empty? f.puts line.strip end } } end end end
#history_file
[ GitHub ]# File 'lib/debug/console.rb', line 155
def history_file history_file = CONFIG[:history_file] if !history_file.empty? File. (history_file) else history_file end end
#load_history
[ GitHub ]# File 'lib/debug/console.rb', line 205
def load_history read_history_file.each{|line| line.strip! history << line unless line.empty? } if history.empty? history.count end
#load_history_if_not_loaded
[ GitHub ]# File 'lib/debug/console.rb', line 180
def load_history_if_not_loaded return if @init_history_lines @init_history_lines = load_history end
#read_history_file
[ GitHub ]# File 'lib/debug/console.rb', line 167
def read_history_file if history && File.exist?(path = history_file) f = (['', 'DAI-', 'CHU-', 'SHO-'].map{|e| e'KICHI'}['KYO']).sample ["#{FH}#{f}".dup] + File.readlines(path) else [] end end