Sha256: a7b682414523348b3576f727e0585ce9796c692784e592a85281031751adfd5a

Contents?: true

Size: 538 Bytes

Versions: 3

Compression:

Stored size: 538 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)
        constants.inject(nil) {|str, s| const_get(s) == state ? s.to_s : str}
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tap-0.18.0 lib/tap/app/state.rb
tap-0.17.1 lib/tap/app/state.rb
tap-0.17.0 lib/tap/app/state.rb