Sha256: db352e88eb1ddda018f60e72bc5513a2dfddfddbaee103893a80b5af92f04728

Contents?: true

Size: 571 Bytes

Versions: 3

Compression:

Stored size: 571 Bytes

Contents

module Tap
  class App
    # The constants defining the possible App states.  
    module State
      READY = 0
      RUN = 1
      STOP = 2
      TERMINATE = 3
      
      module_function
      
      # Returns a string corresponding to the input state value.  
      # Returns nil for unknown states.
      #
      #   State.state_str(0)        # => 'READY'
      #   State.state_str(12)       # => nil
      def state_str(state)
        const = constants.find {|const_name| const_get(const_name) == state }
        const ? const.to_s : nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tap-1.4.0 lib/tap/app/state.rb
tap-1.3.0 lib/tap/app/state.rb
tap-0.19.0 lib/tap/app/state.rb