<commit_before>class Holding
  AVAILABLE_STATUSES = ["Available"]
  AVAILABLE_STATUS_CODES = []
  RECALLABLE_STATUSES = ["Requested"]
  RECALLABLE_STATUS_CODES = ["checked_out", "requested"]
  IN_PROCESSING_STATUSES = ["In Processing", "In Transit"]
  IN_PROCESSING_STATUS_CODES = []
  OFFSITE_STATUSES = ["Offsite Available"]
  OFFSITE_STATUS_CODES = []
  ON_ORDER_STATUSES = ["On Order"]
  ON_ORDER_STATUS_CODES = []
  ILL_STATUSES = ["Request ILL", "Requested", "On Order", "In Processing", "In Transit"]
  ILL_STATUS_CODES = ["checked_out", "billed_as_lost", "requested"]

  attr_reader :service_response

  def initialize(service_response)
    unless service_response.is_a?(ServiceResponse)
      raise ArgumentError.new("Expecting #{service_response} to be a ServiceResponse")
    end
    @service_response = service_response
  end

  # Is this holding available?
  def available?
    AVAILABLE_STATUSES.include?(status) or
      AVAILABLE_STATUS_CODES.include?(status)
  end

  # Is this holding recallable?
  def recallable?
    RECALLABLE_STATUSES.include?(status) or
      RECALLABLE_STATUS_CODES.include?(status_code)
  end

  # Is this holding in processing?
  def in_processing?
    IN_PROCESSING_STATUSES.include?(status) or
      IN_PROCESSING_STATUS_CODES.include?(status_code)
  end

  # Is this holding in offsite?
  def offsite?
    OFFSITE_STATUSES.include?(status) or
      OFFSITE_STATUS_CODES.include?(status_code)
  end

  # Is this holding in on order?
  def on_order?
    ON_ORDER_STATUSES.include?(status) or
      ON_ORDER_STATUS_CODES.include?(status_code)
  end

  # Is this holding in accessible via ILL?
  def ill?
    ILL_STATUSES.include?(status) or
      ILL_STATUS_CODES.include?(status_code)
  end

  # Is this holding checked_out?
  def checked_out?
    status_code.eql?("checked_out")
  end

  # Is this holding requested?
  def requested?
    status.match(/Requested/)
  end

  # View data from the service response
  def view_data
    @view_data ||= service_response.view_data if service_response
  end

  # Original source ID from Primo
  def original_source_id
    @original_source_id ||= view_data[:original_source_id] if view_data
  end

  # Holding's status
  def status
    @status ||= view_data[:status] if view_data
  end

  # Holding's status code
  def status_code
    @status_code ||= view_data[:status_code] if view_data
  end

  # Holding's requestability from Exlibris::Primo::Source::NyuAleph
  def requestability<commit_msg>Refactor a few holding "state" methods for clarity<commit_after>class Holding
  AVAILABLE_STATUSES = ["Available"]
  AVAILABLE_STATUS_CODES = []
  RECALLABLE_STATUSES = ["Requested"]
  RECALLABLE_STATUS_CODES = ["checked_out", "requested"]
  IN_PROCESSING_STATUSES = ["In Processing", "In Transit"]
  IN_PROCESSING_STATUS_CODES = []
  OFFSITE_STATUSES = ["Offsite Available"]
  OFFSITE_STATUS_CODES = []
  ON_ORDER_STATUSES = ["On Order"]
  ON_ORDER_STATUS_CODES = []
  ILL_STATUSES = ["Request ILL", "Requested", "On Order", "In Processing", "In Transit"]
  ILL_STATUS_CODES = ["checked_out", "billed_as_lost", "requested"]

  attr_reader :service_response

  def initialize(service_response)
    unless service_response.is_a?(ServiceResponse)
      raise ArgumentError.new("Expecting #{service_response} to be a ServiceResponse")
    end
    @service_response = service_response
  end

  # Is this holding available?
  def available?
    AVAILABLE_STATUSES.include?(status) or
      AVAILABLE_STATUS_CODES.include?(status)
  end

  # Is this holding recallable?
  def recallable?
    RECALLABLE_STATUSES.include?(status) or
      RECALLABLE_STATUS_CODES.include?(status_code)
  end

  # Is this holding in processing?
  def processing?
    IN_PROCESSING_STATUSES.include?(status) or
      IN_PROCESSING_STATUS_CODES.include?(status_code)
  end
  alias_method :in_processing?, :processing?

  # Is this holding in offsite?
  def offsite?
    OFFSITE_STATUSES.include?(status) or
      OFFSITE_STATUS_CODES.include?(status_code)
  end

  # Is this holding in on order?
  def on_order?
    ON_ORDER_STATUSES.include?(status) or
      ON_ORDER_STATUS_CODES.include?(status_code)
  end

  # Is this holding in accessible via ILL?
  def ill?
    ILL_STATUSES.include?(status) or
      ILL_STATUS_CODES.include?(status_code)
  end

  # Is this holding checked_out?
  def checked_out?
    status_code == "checked_out"
  end

  # Is this holding requested?
  def requested?
    /Requested/ === status
  end

  # View data from the service response
  def view_data
    @view_data ||= service_response.view_data if service_response
  end

  # Original source ID from Primo
  def original_source_id
    @original_source_id ||= view_data[:original_source_id] if view_data
  end

  # Holding's status
  def status
    @status ||= view_data[:status] if view_data
  end

  # Holding's status code
  def status_code
    @status_code ||= view_data[:status_code] if view_data
  end

  # Holding's requestability from Exlibris::Primo::Source::NyuAleph
  def requestability
{'fraction_non_alphanumeric': 0.08798411122144985, 'fraction_numerical': 0.0, 'mean_word_length': 4.351753453772583, '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': '880073', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1671, 'n_words': 387}