Skip to content

Commit

Permalink
rebroke some stuff, but it saw some non-existent trailing spaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatRasputin committed Dec 17, 2024
1 parent 8887ad5 commit 7397c13
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions sorter.lic
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Sorter
return container_name, []
end
end

def sort_items(items)
sorted = {}
items.each do |item|
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 }]
Expand All @@ -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"
Expand All @@ -180,7 +178,6 @@ class Sorter
def cleanup_hook
DownstreamHook.remove('sorter')
end

end

use_table = script.vars.include?('table')
Expand All @@ -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

0 comments on commit 7397c13

Please sign in to comment.