Class TTK::Strategies::Block
In: lib/ttk/strategies/Block.rb
Parent: Strategy

Methods

create   run_impl   test=  

Included Modules

Concrete

Public Class methods

[Source]

# File lib/ttk/strategies/Block.rb, line 14
      def self.create ( *a, &block )
        raise ArgumentError, 'need a block' unless block_given?
        strategy = new(*a)
        strategy.test = block
        strategy
      end

Public Instance methods

[Source]

# File lib/ttk/strategies/Block.rb, line 21
      def test=(block1=nil, &block2)
        if block_given?
          @test = block2
        elsif !block1.nil?
          @test = block1
        else
          raise ArgumentError, 'no block given'
        end

        if @test.is_a?(String)
          str = @test.dup
          @test = proc do eval str end
        end
      end

Protected Instance methods

[Source]

# File lib/ttk/strategies/Block.rb, line 36
      def run_impl
        res = nil
        begin
          res = @test[*@args]
        rescue StatusException => ex
          raise ex
        rescue Exception => ex
          fail(ex)
        end
        pass if res
        fail(res)
      end

[Validate]