Class: Gamefic::Element

Inherits:
Object
  • Object
show all
Includes:
Describable
Defined in:
lib/gamefic/element.rb

Direct Known Subclasses

Entity

Constant Summary

Constants included from Matchable

Matchable::SPLIT_REGEXP

Instance Attribute Summary

Attributes included from Describable

#definite_article, #indefinite_article, #name, #synonyms

Attributes included from Grammar::Person

#person

Attributes included from Grammar::Plural

#plural

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Describable

default_description, default_description=, #definitely, #description, #description=, #has_description?, #indefinitely, #keywords, #proper_named=, #proper_named?, #to_s

Methods included from Matchable

#keywords, #match?

Methods included from Grammar::Plural

#plural?

Constructor Details

#initialize(args = {}) {|_self| ... } ⇒ Element

Returns a new instance of Element.

Yields:

  • (_self)

Yield Parameters:



5
6
7
8
9
10
11
# File 'lib/gamefic/element.rb', line 5

def initialize(args = {})
  self.class.default_attributes.merge(args).each { |key, value|
    send "#{key}=", value
  }
  post_initialize
  yield self if block_given?
end

Class Method Details

.default_attributesObject



22
23
24
# File 'lib/gamefic/element.rb', line 22

def default_attributes
  @default_attributes ||= {}
end

.inherited(subclass) ⇒ Object



26
27
28
# File 'lib/gamefic/element.rb', line 26

def inherited subclass
  subclass.set_default default_attributes
end

.set_default(attrs = {}) ⇒ Object



18
19
20
# File 'lib/gamefic/element.rb', line 18

def set_default attrs = {}
  default_attributes.merge! attrs
end

Instance Method Details

#post_initializeObject



13
14
15
# File 'lib/gamefic/element.rb', line 13

def post_initialize
  # raise NotImplementedError, "#{self.class} must implement post_initialize"
end