From 7397c136dc90f8a395e9a5106e1a83d8dc9d1f4f Mon Sep 17 00:00:00 2001 From: Mike Klobutcher <19937263+ThatRasputin@users.noreply.github.com> Date: Tue, 17 Dec 2024 01:36:55 -0500 Subject: [PATCH] rebroke some stuff, but it saw some non-existent trailing spaces. --- sorter.lic | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sorter.lic b/sorter.lic index 58a2aff4b..71d7aab90 100644 --- a/sorter.lic +++ b/sorter.lic @@ -57,7 +57,7 @@ class Sorter return container_name, [] end end - + def sort_items(items) sorted = {} items.each do |item| @@ -88,17 +88,16 @@ class Sorter clean_item = full_description.sub(/^\s*?\b(?:a|an|some|and|the)\b\s/, '') noun = DRC.get_noun(clean_item) type = get_item_type(clean_item, noun) - sorted[type] ||= {} sorted[type][clean_item] = { - noun: noun, - price: "#{price} #{currency}", - full_description: full_description + noun: noun, + price: "#{price} #{currency}", + full_description: full_description } end end sorted - end + end def get_item_type(item, noun) item_data = get_data('sorting').to_h.merge(get_data('items').to_h) @@ -130,7 +129,7 @@ class Sorter t << :separator t << [{ value: type.strip, alignment: :center, colspan: 2 }] t << :separator - items.each do |item, data| + items.each do |data| t << [data[:full_description].strip, data[:qty]] end end @@ -145,7 +144,6 @@ class Sorter table = Terminal::Table.new do |t| t.title = "Items for sale on #{container_name}" t.headings = ['Item', 'Type', 'Price'] - sorted_items.each do |type, items| t << :separator t << [{ value: type, alignment: :center, colspan: 3 }] @@ -157,7 +155,7 @@ class Sorter end Lich::Messaging.mono(table.to_s) - end + end def display_default(sorted_items, container_name) output = "#{container_name}:\n" @@ -180,7 +178,6 @@ class Sorter def cleanup_hook DownstreamHook.remove('sorter') end - end use_table = script.vars.include?('table') @@ -189,7 +186,6 @@ sorter_instance = Sorter.new(use_table) begin # Keep the script running in the background to monitor incoming lines. while true; sleep(0.1); end - ensure sorter_instance.cleanup_hook # Clean up when the script exits. end