From dbe8ddc5956fd7ee888fa57070e39d116a1c0dfc Mon Sep 17 00:00:00 2001 From: Mahtra <93822896+MahtraDR@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:28:19 +0800 Subject: [PATCH] Rubocop again... --- rummage.lic | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rummage.lic b/rummage.lic index b49cb6443..6a00e8401 100644 --- a/rummage.lic +++ b/rummage.lic @@ -12,9 +12,9 @@ class Rummage def get_container_contents(container) full_contents = Lich::Util.issue_command("rummage #{container}", /^You rummage .* but there is nothing in there\.$|^You rummage .* and see (.*)\./, quiet: true) - + rummage_line = full_contents.find { |line| line.start_with?('You rummage') } - + if rummage_line =~ /but there is nothing in there/ container_name = rummage_line.match(/^You rummage (.*?) but/)[1] return [container_name, []] @@ -24,14 +24,14 @@ class Rummage return [container_name, DRC.list_to_array(contents)] end end - + def sort_items(items) sorted = {} items.each do |item| clean_item = item.sub(/^\s*?\b(?:a|an|some|and|the)\b\s/, '').chomp('.') noun = DRC.get_noun(clean_item) type = get_item_type(clean_item, noun) - + if sorted[type] if sorted[type][clean_item] sorted[type][clean_item][:qty] += 1 @@ -48,14 +48,14 @@ class Rummage def get_item_type(item, noun) item_data = get_data('sorting').to_h.merge(get_data('items').to_h) category = 'Other' - + item_data.each do |key, value| if noun =~ /#{value.join('$|').concat('$')}/i || item =~ /(?:#{value.join('$|').concat('$')})/i category = key.to_s.sub(/_nouns|_types/, '').capitalize break end end - + category end @@ -63,13 +63,13 @@ class Rummage table = Terminal::Table.new do |t| t.title = "Contents of #{container_name.strip}" t.style = { border_x: "-", border_i: "+", border_y: "|" } - + if sorted_items.empty? t << [{ value: "This container is empty", alignment: :center, colspan: 2 }] else t.headings = ['Item', 'Qty.'] sorted_types = sorted_items.keys.sort_by { |type| type == "Other" ? [1, type] : [0, type] } - + sorted_types.each do |type| items = sorted_items[type] t << :separator