<commit_before>class Robot
  class Direction
    ALL_STR = %w(NORTH EAST SOUTH WEST)

    def self.Direction direction
      return direction if direction.is_a? Direction

      Direction.new direction
    end

    attr_reader :name

    def initialize name
      raise ArgumentError, "#{name}: unknown direction" \
	unless ALL_STR.include? name

      @name = name
    end

    NORTH = Direction 'NORTH'
    EAST = Direction 'EAST'
    SOUTH = Direction 'SOUTH'
    WEST = Direction 'WEST'
    ALL = [NORTH, EAST, SOUTH, WEST].map! { |d| d.freeze }

    def == other
      @name == other.name
    end

    def next
      case self
      when NORTH then EAST
      when EAST then SOUTH
      when SOUTH then WEST
      when WEST then NORTH
      end
    end

    def next!
      @name = self.next.name
      self
    end

    def prev
      case self
      when NORTH then WEST
      when WEST then SOUTH
      when SOUTH then EAST
      when EAST then NORTH
      end
    end

    def prev!
      @name = prev.name
      self
    end

    def to_s
      @name
    end
  end
end

module Kernel
  def Direction direction
    Robot::Direction::Direction direction
  end
end<commit_msg>* Refactor.<commit_after>class Robot
  class Direction
    ALL_STR = %w(NORTH EAST SOUTH WEST)

    def self.Direction direction
      return direction if direction.is_a? Direction

      Direction.new direction
    end

    attr_reader :name

    def initialize name
      raise ArgumentError, "#{name}: unknown direction" \
	unless ALL_STR.include? name

      @name = name
    end

    NORTH = Direction 'NORTH'
    EAST = Direction 'EAST'
    SOUTH = Direction 'SOUTH'
    WEST = Direction 'WEST'
    ALL = [NORTH, EAST, SOUTH, WEST].map! { |d| d.freeze }

    def == other
      @name == other.name
    end

    def next
      case self
      when NORTH then EAST
      when EAST then SOUTH
      when SOUTH then WEST
      when WEST then NORTH
      end
    end

    def next!
      replace self.next
    end

    def prev
      case self
      when NORTH then WEST
      when WEST then SOUTH
      when SOUTH then EAST
      when EAST then NORTH
      end
    end

    def prev!
      replace prev
    end

    def to_s
      @name
    end

    private

    def replace other
      @name = other.name
      self
    end
  end
end

module Kernel
  def Direction direction
    Robot::Direction::Direction direction
  end
end
{'fraction_non_alphanumeric': 0.05679933665008292, 'fraction_numerical': 0.0, 'mean_word_length': 1.9037304452466908, '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': '5847163', 'n_tokens_mistral': 815, 'n_tokens_neox': 768, 'n_words': 268}