Sha256: aaaf80ce26fbcb31b838040ecb2361869fbb3cf36d8cb0ec172ce11998c669f1

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

module Finite

  # The State class. Represents a state in the state machine.
  class State
    attr_reader :name

    # Create a new state
    #
    # @param name [Symbol] the name of the state
    def initialize(name)
      @name = name
    end

    # Overide the == method for state
    #
    # @param state [Object] the state your comparing to
    # @return true if they are equal false if not
    def ==(state)
      if state.is_a? Symbol
        @name == state
      elsif state.is_a? State
        @name == state.name
      else
        false
      end
    end

    # overrriden for puts and print
    def to_s
      @name.to_s
    end

    # Overridden for p
    def inspect
      @name
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finite-1.1.0 lib/finite/state.rb
finite-1.0.0 lib/finite/state.rb