Sha256: 632f5a7df7a235d85cb1636b7a182e78f6750d6e24254d0c665818ae1e78738f

Contents?: true

Size: 842 Bytes

Versions: 9

Compression:

Stored size: 842 Bytes

Contents

# frozen-string-literal: true

module Bioshogi
  module BoardParser
    class Base
      class << self
        def accept?
          raise NotImplementedError, "#{__method__} is not implemented"
        end

        def parse(source, options = {})
          new(source, options).tap(&:parse)
        end
      end

      def initialize(source, options = {})
        @source = source
        @options = options
      end

      delegate *[
        :sorted_soldiers,
        :location_split,
        :place_as_key_table,
        :location_adjust,
      ], to: :soldiers

      def soldiers
        soldier_box
      end

      def soldier_box
        @soldier_box ||= SoldierBox.new
      end

      private

      def shape_lines
        @shape_lines ||= Source.wrap(@source).to_s.remove(/\s*#.*/).strip.lines.to_a
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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