Module: Standardized

Included in:
Gamefic::Entity
Defined in:
lib/gamefic-standard/modules/standardized.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#itemized=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


3
4
5
# File 'lib/gamefic-standard/modules/standardized.rb', line 3

def itemized=(value)
  @itemized = value
end

#locale_descriptionString?

An optional description to use when itemizing entities in room descriptions. The locale_description will be used instead of adding the entity’s name to a list.

Returns:

  • (String, nil)


13
14
15
# File 'lib/gamefic-standard/modules/standardized.rb', line 13

def locale_description
  @locale_description
end

#portable=(value) ⇒ Boolean (writeonly)

Returns:

  • (Boolean)


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

def portable=(value)
  @portable = value
end

Instance Method Details

#attached=(bool) ⇒ Object

Parameters:

  • bool (Boolean)


35
36
37
38
39
40
41
42
# File 'lib/gamefic-standard/modules/standardized.rb', line 35

def attached=(bool)
  @attached = if parent.nil?
                # @todo Log attachment failure
                false
              else
                bool
              end
end

#attached?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gamefic-standard/modules/standardized.rb', line 30

def attached?
  @attached ||= false
end

#itemized?Boolean

Itemized entities are automatically listed in room descriptions.

Returns:

  • (Boolean)


18
19
20
# File 'lib/gamefic-standard/modules/standardized.rb', line 18

def itemized?
  @itemized
end

#parent=(new_parent) ⇒ Object



44
45
46
47
# File 'lib/gamefic-standard/modules/standardized.rb', line 44

def parent=(new_parent)
  self.attached = false unless new_parent == parent
  super
end

#portable?Boolean

Portable entities can be taken with TAKE actions.

Returns:

  • (Boolean)


25
26
27
# File 'lib/gamefic-standard/modules/standardized.rb', line 25

def portable?
  @portable
end

#roomRoom

The entity’s parent room (i.e., the closest ascendant that is a Room).

Returns:



52
53
54
55
56
# File 'lib/gamefic-standard/modules/standardized.rb', line 52

def room
  ascendant = parent
  ascendant = ascendant.parent until ascendant.is_a?(Room) || ascendant.nil?
  ascendant
end