Class: DEBUGGER__::Console
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/debug/console.rb |
Constant Summary
-
FH =
# File 'lib/debug/console.rb', line 186"# Today's OMIKUJI: "
Class Method Summary
- .new ⇒ Console constructor
Instance Method Summary
Constructor Details
.new ⇒ Console
# File 'lib/debug/console.rb', line 197
def initialize @init_history_lines = nil end
Instance Method Details
#deactivate
[ GitHub ]# File 'lib/debug/console.rb', line 207
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 176
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 226
def load_history read_history_file.count{|line| line.strip! history << line unless line.empty? } end
#load_history_if_not_loaded
[ GitHub ]# File 'lib/debug/console.rb', line 201
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 188
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