Sha256: 3e647925f7aafb260754e3c62f54d22b49e29a7868ec37f866c2512443e38226

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

require 'spy_alley_application/types/board_space'

module SpyAlleyApplication
  module Models
    module BoardSpaces
      class SpyAlleyEntrance < Dry::Struct
        @@can_handle_spy_alley_entrance = ::Types.Interface(:handle_spy_alley_entrance)
        def self.new(id:, next_space:, branch_space: nil, &block)
          o = SpyAlleyEntrance.allocate
          branch_space ||= yield(o)
          o.send(:initialize, **{id: id, next_space: next_space, branch_space: branch_space})
          o
        end

        def initialize(id:, next_space:, branch_space:, &block)
          @id = ::Types::Coercible::Integer.call(id)
          @next_space = SpyAlleyApplication::Types::BoardSpace.call(next_space)
          @branch_space = SpyAlleyApplication::Types::BoardSpace.call(branch_space)
        end

        def id;@id;end
        def next_space;@next_space;end
        def branch_space;@branch_space;end
        def in_spy_alley?;false;end
        def to_h;{id: id};end
        def [](key)
          id if key.to_sym.eql?(:id)
        end

        def accept(visitor, **args)
          @@can_handle_spy_alley_entrance.(visitor)
          visitor.handle_spy_alley_entrance(self, args)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spy_alley_application-0.3.2 lib/spy_alley_application/models/board_spaces/spy_alley_entrance.rb
spy_alley_application-0.3.1 lib/spy_alley_application/models/board_spaces/spy_alley_entrance.rb
spy_alley_application-0.3.0 lib/spy_alley_application/models/board_spaces/spy_alley_entrance.rb