<commit_before>module Exlibris
  module Primo
    module Source
      class NyuAleph
        class Item
          def initialize(item)
            @item_id = item["href"].match(/items\/(.+)$/)[1]
            @adm_library_code = item["z30"]["translate_change_active_library"]
            @sub_library_code = item["z30_sub_library_code"].strip
            @collection_code = item["z30_collection_code"]
            @sequence_number = item["z30"]["z30_item_sequence"].strip
            @barcode = item["z30"]["z30_barcode"]
            @item_status_code = item["z30_item_status_code"]
            @item_process_status_code = item["z30_item_process_status_code"]
            @item_status = item["z30"]["z30_item_status"]
            @item_process_status = item["z30"]["z30_item_process_status"]
            @circulation_status = item["status"]
            @queue = item["queue"]
            @hol_doc_number = item["z30"]["z30_hol_doc_number"]
            @classification = item["z30"]["z30_call_no"]
            @description = item["z30"]["z30_description"]
            @call_number = call_number(item)
          end

          # This kinda sucks. Way too clever. Completely unreadable.
          def to_h
            @hash = Hash[JSON.parse(to_json).map{ |k, v| [k.to_sym, v] }]
            # @hash ||= Hash[
            #   *instance_variables.collect { |ivar| 
            #     [ivar.to_s.gsub('@', '').to_sym, instance_variable_get(ivar)] }.flatten]
          end
<commit_msg>Use the convoluted Item#to_h for now so that we can pass around objects<commit_after>module Exlibris
  module Primo
    module Source
      class NyuAleph
        class Item
          def initialize(item)
            @item_id = item["href"].match(/items\/(.+)$/)[1]
            @adm_library_code = item["z30"]["translate_change_active_library"]
            @sub_library_code = item["z30_sub_library_code"].strip
            @collection_code = item["z30_collection_code"]
            @sequence_number = item["z30"]["z30_item_sequence"].strip
            @barcode = item["z30"]["z30_barcode"]
            @item_status_code = item["z30_item_status_code"]
            @item_process_status_code = item["z30_item_process_status_code"]
            @item_status = item["z30"]["z30_item_status"]
            @item_process_status = item["z30"]["z30_item_process_status"]
            @circulation_status = item["status"]
            @queue = item["queue"]
            @hol_doc_number = item["z30"]["z30_hol_doc_number"]
            @classification = item["z30"]["z30_call_no"]
            @description = item["z30"]["z30_description"]
            @call_number = call_number(item)
          end

          # This kinda sucks. Way too clever. Completely unreadable.
          def to_h
            @hash ||= Hash[
              *(instance_variables.collect { |ivar| 
                [ivar.to_s.gsub('@', '').to_sym, instance_variable_get(ivar)]
              }.flatten)
            ]
          end

{'fraction_non_alphanumeric': 0.1293481931779804, 'fraction_numerical': 0.02634245187436677, 'mean_word_length': 2.3812785388127855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1449007', 'n_tokens_mistral': 955, 'n_tokens_neox': 930, 'n_words': 146}