Sha256: 37368c3da9f22ccaf83dce1bb2abc6aa2033d2d49187df2030d908be9acb18cd
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module MiniKraken module Core # A bookmark is a placeholder for events of significance for # manipulating the move queue of a blackboard. # The events that involve bookmarks are: # - enter_scope (when executing fresh expression) # - leave_scope (when all solutions for given scope were found) # - add_bt_point (when a backtrack point must be added) # - remove_bt_point (when a backtrack point must be retracted) # - next_alternative (when an alternative solution is searched) # - fail! (when the current solution fails) class Bookmark # @return [Symbol] One of: :scope, :bt_point attr_reader :kind # @return [Integer] An unique serial number. attr_reader :ser_num # @param aKind [Symbol] must be one of: :scope, :bt_point # @param aSerialNumber [Integer] a serial number def initialize(aKind, aSerialNumber) @kind = validated_kind(aKind) @ser_num = aSerialNumber end # Equality comparison # @param other [Bookmark, Object] # return [Boolean] def ==(other) ser_num == other.ser_num end private def validated_kind(aKind) if aKind != :scope && aKind != :bt_point raise StandardError, "Invalid kind: #{aKind}" end aKind end end # class end # module end # module
Version data entries
4 entries across 4 versions & 1 rubygems