Sha256: 2253182936a373e788923a496a5b9d9159d38987d3127926734eb9913ec491b8

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true

module Gamefic
  module Standard
    # A module for entities that are both openable and lockable.
    #
    module Lockable
      include Openable

      attr_accessor :lock_key

      def locked=(bool)
        @locked = bool
        @open = false if @locked
      end

      def open=(bool)
        @open = bool
        @locked = false if @open
      end

      def locked?
        @locked ||= false
      end

      def unlocked?
        !locked?
      end

      def lock_key?
        !@lock_key.nil?
      end
      alias has_lock_key? lock_key?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gamefic-standard-3.3.0 lib/gamefic-standard/lockable.rb