Sha256: f426129292fbdf0d93652d8666a8225b6d12eda1f34f17b6f02a50850cbc0211

Contents?: true

Size: 1.21 KB

Versions: 9

Compression:

Stored size: 1.21 KB

Contents

# frozen-string-literal: true

module Bioshogi
  module Formatter
    class Runner
      attr_accessor :formatter
      attr_accessor :container

      def initialize(formatter, container)
        @formatter = formatter
        @container = container
      end

      def call
        begin
          @formatter.pi.move_infos.each.with_index do |info, i|
            if @formatter.parser_options[:debug]
              p container
            end
            if @formatter.parser_options[:callback]
              @formatter.parser_options[:callback].call(container)
            end
            if @formatter.parser_options[:turn_limit] && container.turn_info.display_turn >= @formatter.parser_options[:turn_limit]
              break
            end
            container.execute(info[:input], used_seconds: formatter.used_seconds_at(i))
          end
        rescue CommonError => error
          if v = @formatter.parser_options[:typical_error_case]
            case v
            when :embed
              @formatter.pi.error_message = error.message
            when :skip
            else
              raise MustNotHappen
            end
          else
            raise error
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bioshogi-0.0.15 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.14 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.10 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.9 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.8 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.7 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.5 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.4 lib/bioshogi/formatter/runner.rb
bioshogi-0.0.3 lib/bioshogi/formatter/runner.rb