lib/zakuro/era/japan/gengou/alignment/line.rb in zakuro-0.7.2 vs lib/zakuro/era/japan/gengou/alignment/line.rb in zakuro-0.8.0

- old
+ new

@@ -70,11 +70,11 @@ # # @return [Array<LinearGengou>] 元号 # def get(start_date:, last_date:) result = [] - @list.each do |gengou| + list.each do |gengou| next if gengou.out?(start_date: start_date, last_date: last_date) # 1日でも範囲内であれば対象とみなす result.push(gengou) end @@ -89,11 +89,11 @@ # # @return [Array<LinearGengou>] 元号 # def get_by_name(name:) result = [] - @list.each do |gengou| + list.each do |gengou| result.push(gengou) if gengou.name == name end result end @@ -108,11 +108,12 @@ # @return [Array<LinearGengou>] 重複分元号 # def rest(list: []) result = [] - @list.each do |gengou| + inner_list = @list + inner_list.each do |gengou| result |= and!(rest: list, other: gengou) end Division.connect(list: result) end @@ -121,18 +122,19 @@ # 空き範囲に元号を登録する # # @param [Array<LinearGengou>] list 元号 # def insert(list: []) + inner_list = @list surplus_result = list.clone - @list.each do |gengou| + inner_list.each do |gengou| surplus_result = not!(surplus: surplus_result, other: gengou) end surplus_result = Division.connect(list: surplus_result) surplus_result.each do |gengou| - @list.push(gengou) + inner_list.push(gengou) end end # # 重複した範囲を返す