Module: Lockable

Includes:
Openable
Included in:
Container, Door
Defined in:
lib/gamefic-standard/modules/lockable.rb

Overview

A module for entities that are both openable and lockable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Openable

#accessible?, #closed?, #open?

Instance Attribute Details

#lock_keyObject

Returns the value of attribute lock_key.



6
7
8
# File 'lib/gamefic-standard/modules/lockable.rb', line 6

def lock_key
  @lock_key
end

Instance Method Details

#lock_key?Boolean Also known as: has_lock_key?

Returns:

  • (Boolean)


28
29
30
# File 'lib/gamefic-standard/modules/lockable.rb', line 28

def lock_key?
  !@lock_key.nil?
end

#locked=(bool) ⇒ Object



8
9
10
11
12
13
# File 'lib/gamefic-standard/modules/lockable.rb', line 8

def locked=(bool)
  @locked = bool
  if @locked == true
    self.open = false
  end
end

#locked?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/gamefic-standard/modules/lockable.rb', line 20

def locked?
  @locked ||= false
end

#open=(bool) ⇒ Object



15
16
17
18
# File 'lib/gamefic-standard/modules/lockable.rb', line 15

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

#unlocked?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gamefic-standard/modules/lockable.rb', line 24

def unlocked?
  !locked?
end