class Patient_Data attr_accessor :patient_id attr_accessor :name attr_accessor :symptom attr_accessor :time_check_in attr_accessor :time_check_out attr_accessor :note attr_accessor :original_data def self.init # 文件的相对路径 filename = "Input.txt" $data_patients = [] File.foreach(filename) do |line| original_data = line.chomp $data_patients << Patient_Data.new(original_data) end end def initialize(str) arr = str.split(" ") @patient_id = arr[0] @name = arr[1] @symptom = arr[2] @time_check_in = arr[3] @time_check_out = arr[4] @note = arr[5] @original_data = str end def self.find_data_by_id result = $data_patients.select{|item| item.patient_id == $game_variables[40].to_s} return result.map{|item| item.original_data} end end
p Patient_Data.find_data_by_id
706.68 KB, 下载次数: 37
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |