lib/galaxy_converter/detector.rb in galaxy_converter-3.1.2 vs lib/galaxy_converter/detector.rb in galaxy_converter-3.1.3
- old
+ new
@@ -7,12 +7,11 @@
GOODS_RULE = /([\w+\s]+) (\w+) is (\d+) credits/i
attr_reader :converter
def initialize(notes, converter = Converter)
- notes = notes.reject(&:question?)
- @credits, @assertions = notes.partition { |note| note.instance_of? Credit }
+ @credits, @assertions = notes.reject(&:question?).partition { |note| note.instance_of? Credit }
@converter = converter.new(mapping)
end
def goods
@goods ||= @credits.reduce({}) do |acc, note|
@@ -25,10 +24,10 @@
acc
end
end
private def mapping
- @mapping ||= @assertions.reduce({}) do |acc, note|
+ @assertions.reduce({}) do |acc, note|
matching = note.body.match(MAPPING_RULE)
next acc unless matching
unit, roman = matching.captures
acc[unit.strip] = roman.upcase
acc