Module: Gamefic::Standard::Lockable

Includes:
Openable
Included in:
Container, Door
Defined in:
lib/gamefic/standard/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, #close, #closed?, #open, #open?

Instance Attribute Details

#lock_keyObject

Returns the value of attribute lock_key.



10
11
12
# File 'lib/gamefic/standard/lockable.rb', line 10

def lock_key
  @lock_key
end

Instance Method Details

#lockObject



12
13
14
# File 'lib/gamefic/standard/lockable.rb', line 12

def lock
  self.locked = true
end

#lock_key?Boolean Also known as: has_lock_key?

Returns:

  • (Boolean)


38
39
40
# File 'lib/gamefic/standard/lockable.rb', line 38

def lock_key?
  !@lock_key.nil?
end

#locked=(bool) ⇒ Object



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

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

#locked?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gamefic/standard/lockable.rb', line 30

def locked?
  @locked ||= false
end

#open=(bool) ⇒ Object



25
26
27
28
# File 'lib/gamefic/standard/lockable.rb', line 25

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

#unlockObject



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

def unlock
  self.locked = false
end

#unlocked?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/gamefic/standard/lockable.rb', line 34

def unlocked?
  !locked?
end