class Condition::Param
Public Class Methods
get_reader()
click to toggle source
# File lib/condition/param.rb, line 10 def self.get_reader() if @@reader.nil? @@reader = Condition::Reader::RooReader.new end @@reader end
new(path, sheet_index=0, blks: nil, reader: nil)
click to toggle source
# File lib/condition/param.rb, line 17 def initialize(path, sheet_index=0, blks: nil, reader: nil) if blks.nil? rd = reader.nil? ? Condition::Param.get_reader() : reader blocks = rd.read_sheet(path, sheet_index) set_blocks(blocks) else set_blocks(blks) end end
set_reader(reader)
click to toggle source
# File lib/condition/param.rb, line 6 def self.set_reader(reader) @@reader = reader end
Public Instance Methods
check(name, data)
click to toggle source
# File lib/condition/param.rb, line 51 def check(name, data) item = item(name) raise "#{name} not found in param" if item.nil? item.clear_used_values index = 0 data.each do |line| item.check_line(line, index) index += 1 end raise "#{item.name} not exists row" if item.is_remain_value end
get(name, index=nil)
click to toggle source
# File lib/condition/param.rb, line 44 def get(name, index=nil) item = item(name) return nil if !item return item.values if !index return item.values[index] end
item(name)
click to toggle source
# File lib/condition/param.rb, line 40 def item(name) @item_map[name.to_sym] end
post(storage)
click to toggle source
# File lib/condition/param.rb, line 71 def post(storage) @item_map.each_value do |item| item.clear_used_values list = storage.all(item) index = 0 list.each do |line| item.check_line(line, index) index += 1 end raise "#{item.name} not exists row" if item.is_remain_value end end
pre(storage, default=nil)
click to toggle source
# File lib/condition/param.rb, line 63 def pre(storage, default=nil) @item_map.each_value do |item| storage.delete(item) storage.insert(item, default) storage.exec_after(item) end end
set_blocks(blocks)
click to toggle source
# File lib/condition/param.rb, line 27 def set_blocks(blocks) @item_map = {} item_list = [] blocks.each do |rows| item = Condition::ParamItem.new(rows) @item_map[item.name] = item item_list << item end item_list.reverse.each do |it| it.apply_ref(self) end end