lib/plu.rb in plu-0.2.0 vs lib/plu.rb in plu-0.3.0
- old
+ new
@@ -1,7 +1,11 @@
-require "csv"
+# stdlib
+require "json"
+# modules
+require_relative "plu/version"
+
class PLU
def initialize(number)
@number = number.to_s
end
@@ -19,18 +23,11 @@
def retailer_assigned?
name.to_s.start_with?("Retailer Assigned")
end
- # TODO more items
def self.all
- @all ||= begin
- all = {}
- CSV.foreach File.expand_path("../../plu_codes.csv", __FILE__), headers: true do |row|
- all[row["PLU Code"]] = row["Name"]
- end
- all
- end
+ @all ||= JSON.load_file(File.expand_path("../plu_codes.json", __dir__))
end
protected
def base