Sha256: da22afcc22806fae06a6907c4390474a6c7814dd922f9de931a87245faab8d9f

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

# lib/stair_master/conditions/base.rb
##
##
##
module StairMaster
  module Conditions
    class Base
      attr_reader   :type # :if || :unless
      attr_accessor :method_name

      def initialize(step, type, method_name)
        @step         = step
        @type         = type
        @method_name  = method_name
      end

      ## Methods ------------------------------------------

      def available?
        raise NotImplmenetedError
      end

      def not_available?
        raise NotImplmenetedError
      end

      def description
        raise NotImplementedError
      end

      def test(context)
        case @type.to_sym
        when :if
          return context.send(@method_name.to_sym)
        when :unless
          return !context.send(@method_name.to_sym)
        else
          return false
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stair_master-0.0.3 lib/stair_master/conditions/base.rb
stair_master-0.0.2 lib/stair_master/conditions/base.rb
stair_master-0.0.1 lib/stair_master/conditions/base.rb