class Arrowhead
  # This seriously belongs in a database.
  CLASSIFICATIONS = {
    far_west: {
      notched: "Archaic Side Notch",
      stemmed: "Archaic Stemmed",
      lanceolate: "Agate Basin",
      bifurcated: "Cody",
    },
    northern_plains: {
      notched: "Besant",
      stemmed: "Archaic Stemmed",
      lanceolate: "Humboldt Constricted Base",
      bifurcated: "Oxbow",
    },
  }

  # FIXME: I don't have time to deal with this.
  def self.classify(region, shape)
    if CLASSIFICATIONS.include? region
      shapes = CLASSIFICATIONS[region]
      if shapes.include? shape
        arrowhead = shapes[shape]
        "You have a(n) '#{arrowhead}' arrowhead. Probably priceless."
      else
        raise "Unknown shape value. Are you sure you know what you're talking about?"
      end
    else
      raise "Unknown region, please provide a valid region."
    end
  end
end

puts Arrowhead.classify(:northern_plains, :bifurcated)

begin
  Arrowhead.classify(:southern_plains, :bifurcated)
rescue => e
  puts "Unknown region raises: #{e.class}: #{e.message}"
end

begin
  Arrowhead.classify(:northern_plains, :plain)
rescue => e
  puts "Unknown shape raises: #{e.class}: #{e.message}"
end

class Arrowhead
  # This seriously belongs in a database.
  CLASSIFICATIONS = {
    far_west: {
      notched: "Archaic Side Notch",
      stemmed: "Archaic Stemmed",
      lanceolate: "Agate Basin",
      bifurcated: "Cody",
    },
    northern_plains: {
      notched: "Besant",
      stemmed: "Archaic Stemmed",
      lanceolate: "Humboldt Constricted Base",
      bifurcated: "Oxbow",
    },
  }

  def self.classify(region, shape)
    unless CLASSIFICATIONS.include? region
      raise "Unknown region, please provide a valid region."
    end

    shapes = CLASSIFICATIONS[region]

    unless shapes.include? shape
      raise "Unknown shape value. Are you sure you know what you're talking about?"
    end

    arrowhead = shapes[shape]

    "You have a(n) '#{arrowhead}' arrowhead. Probably priceless."
  end
end

puts Arrowhead.classify(:northern_plains, :bifurcated)

begin
  Arrowhead.classify(:southern_plains, :bifurcated)
rescue => e
  puts "Unknown region raises: #{e.class}: #{e.message}"
end

begin
  Arrowhead.classify(:northern_plains, :plain)
rescue => e
  puts "Unknown shape raises: #{e.class}: #{e.message}"
end

Move error conditions near their conditions
Move error conditions near their conditions

This was an interesting exercise. The process was actually very
straightforward, but only because I had read the Ruby Style Guide
recently. I remembered the style guide to fail out of a method
as soon as possible. That meant that I should move the code in the
outer else statement to the top to fail immediately if the
condition was met. I saw that the condition needed to be changed
from expecting true to expecting false, so I changed it to unless
instead of if. I then did the same two steps for the inner if
statement.
