Method: AppMainBase#add_history
- Defined in:
- lib/server_app_base.rb
#add_history(file, history_data, max = 10) ⇒ Object
履歴の保存
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/server_app_base.rb', line 43 def add_history(file, history_data, max = 10) begin buf = File.read "#{$home_dir}history/#{file}" rescue buf = "" end data = eval(buf) if data == nil data = [] end if history_data.to_s != "" data.prepend history_data end data = data.uniq[0..max - 1] File.open("#{$home_dir}history/#{file}", "w") do |f| f.write JSON.pretty_generate data end end |