Module: Gamefic::Grammar::Attributes

Included in:
Entity
Defined in:
lib/gamefic/grammar/attributes.rb

Overview

A collection of attributes that enable grammar features for entities, such as selecting their correct pronouns.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#genderSymbol

The gender of the object. Supported values are :male, :female, :neutral, and :other. Use :neutral for objects that don’t have a gender (i.e., “it”). Use :other for people or characters that have an unspecified or non-binary gender (i.e., “they”).

Returns:

  • (Symbol)


21
22
23
# File 'lib/gamefic/grammar/attributes.rb', line 21

def gender
  @gender ||= :neutral
end

#plural=(value) ⇒ Object (writeonly)

See Also:



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

def plural=(value)
  @plural = value
end

Instance Method Details

#maybe_plural(singular_text, plural_text = "#{singular_text}s") ⇒ String

Parameters:

  • singular_text (String)
  • plural_text (String) (defaults to: "#{singular_text}s")

Returns:

  • (String)


43
44
45
# File 'lib/gamefic/grammar/attributes.rb', line 43

def maybe_plural(singular_text, plural_text = "#{singular_text}s")
  plural? ? plural_text : singular_text
end

#objectiveObject Also known as: him, them



59
60
61
# File 'lib/gamefic/grammar/attributes.rb', line 59

def objective
  Pronoun.objective self
end

#objective_Object Also known as: him_, them_, Him, Them



65
66
67
# File 'lib/gamefic/grammar/attributes.rb', line 65

def objective_
  Pronoun.objective_ self
end

#otherize(default, **opts) ⇒ String

Select a phrase based on the entity’s subjective pronoun.

Examples:

entity.otherize('is', they: 'are')

Parameters:

  • default (String)
  • opts (Hash)

Returns:

  • (String)


55
56
57
# File 'lib/gamefic/grammar/attributes.rb', line 55

def otherize default, **opts
  opts[subjective.to_sym] || default
end

#personObject

For now, the object’s person is always assumed to be third (he/she/it/they). A future version of this library might support first (I/me) and second (you).



36
37
38
# File 'lib/gamefic/grammar/attributes.rb', line 36

def person
  3
end

#plural?Boolean

True if the object should be referred to in the plural, e.g., “they” instead of “it.”

Returns:

  • (Boolean)


29
30
31
# File 'lib/gamefic/grammar/attributes.rb', line 29

def plural?
  @plural ||= false
end

#possessiveObject Also known as: his, their, its



90
91
92
# File 'lib/gamefic/grammar/attributes.rb', line 90

def possessive
  Pronoun.possessive self
end

#possessive_Object Also known as: his_, their_, its_, His, Their, Its



97
98
99
# File 'lib/gamefic/grammar/attributes.rb', line 97

def possessive_
  Pronoun.possessive_ self
end

#reflexiveObject Also known as: himself, herself, itself, themselves, themself



107
108
109
# File 'lib/gamefic/grammar/attributes.rb', line 107

def reflexive
  Pronoun.reflexive self
end

#reflexive_Object Also known as: himself_, herself_, itself_, themselves_, themself_, Himself, Herself, Itself, Themselves, Themself



116
117
118
# File 'lib/gamefic/grammar/attributes.rb', line 116

def reflexive_
  Pronoun.reflexive_ self
end

#subjectiveObject Also known as: he, she, they



73
74
75
# File 'lib/gamefic/grammar/attributes.rb', line 73

def subjective
  Pronoun.subjective self
end

#subjective_Object Also known as: he_, she_, they_, He, She, They



80
81
82
# File 'lib/gamefic/grammar/attributes.rb', line 80

def subjective_
  Pronoun.subjective_ self
end