Sha256: c2531dd66d2f7d8a09979bd28353fbdf9903e856448d35495a48eee6e088fbb9

Contents?: true

Size: 687 Bytes

Versions: 9

Compression:

Stored size: 687 Bytes

Contents

# frozen-string-literal: true

module Bioshogi
  module BoardParser
    class << self
      def accept?(source)
        !!parser_class_find(source)
      end

      def parse(source, options = {})
        parser = parser_class_find(source)
        unless parser
          raise FileFormatError, "盤面のフォーマットが不明です : #{source}"
        end
        parser.parse(source, options)
      end

      private

      def parser_class_find(source)
        support_parsers.find {|e| e.accept?(source) }
      end

      def support_parsers
        [
          KakinokiBoardParser,
          CsaBoardParser,
          SfenBoardParser,
        ]
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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