Module: Gamefic::Grammar::Pronoun
- Defined in:
- lib/gamefic/grammar/pronoun.rb
Overview
Methods to select pronouns based on an entity’s attributes, such as gender.
Constant Summary collapse
- MAP_KEYS =
%i[subjective objective possessive reflexive].freeze
- MAPS =
{ [1, :singular] => Hash[MAP_KEYS.zip(%w[I me my myself])], [2, :singular] => Hash[MAP_KEYS.zip(%w[you you your yourself])], [3, :singular] => Hash[MAP_KEYS.zip(%w[it it its itself])], [3, :singular, :male] => Hash[MAP_KEYS.zip(%w[he him his himself])], [3, :singular, :female] => Hash[MAP_KEYS.zip(%w[she her her herself])], [3, :singular, :other] => Hash[MAP_KEYS.zip(%w[they them their themselves])], [3, :singular, :neutral] => Hash[MAP_KEYS.zip(%w[it it its itself])], [1, :plural] => Hash[MAP_KEYS.zip(%w[we us our ourselves])], [2, :plural] => Hash[MAP_KEYS.zip(%w[you you your yourselves])], [3, :plural] => Hash[MAP_KEYS.zip(%w[they them their themselves])] }.freeze
Class Method Summary collapse
- .objective(entity) ⇒ String (also: them)
- .objective_(entity) ⇒ String (also: them_)
- .possessive(entity) ⇒ String (also: their)
- .possessive_(entity) ⇒ String (also: their_)
- .prounoun_map(entity) ⇒ Hash
- .reflexive(entity) ⇒ String (also: themselves, themself)
- .reflexive_(entity) ⇒ String (also: themselves_, themself_)
- .subjective(entity) ⇒ String (also: they, he, she)
- .subjective_(entity) ⇒ String (also: they_, he_, she_)
Class Method Details
.objective(entity) ⇒ String Also known as: them
46 47 48 |
# File 'lib/gamefic/grammar/pronoun.rb', line 46 def objective(entity) prounoun_map(entity)[:objective] end |
.objective_(entity) ⇒ String Also known as: them_
53 54 55 |
# File 'lib/gamefic/grammar/pronoun.rb', line 53 def objective_(entity) objective(entity).cap_first end |
.possessive(entity) ⇒ String Also known as: their
60 61 62 |
# File 'lib/gamefic/grammar/pronoun.rb', line 60 def possessive(entity) prounoun_map(entity)[:possessive] end |
.possessive_(entity) ⇒ String Also known as: their_
67 68 69 |
# File 'lib/gamefic/grammar/pronoun.rb', line 67 def possessive_(entity) possessive(entity).cap_first end |
.prounoun_map(entity) ⇒ Hash
90 91 92 93 94 |
# File 'lib/gamefic/grammar/pronoun.rb', line 90 def prounoun_map(entity) plurality = (entity.plural? ? :plural : :singular) MAPS[[entity.person || 3, plurality, entity.gender]] || MAPS[[entity.person || 3, plurality]] end |
.reflexive(entity) ⇒ String Also known as: themselves, themself
74 75 76 |
# File 'lib/gamefic/grammar/pronoun.rb', line 74 def reflexive(entity) prounoun_map(entity)[:reflexive] end |
.reflexive_(entity) ⇒ String Also known as: themselves_, themself_
82 83 84 |
# File 'lib/gamefic/grammar/pronoun.rb', line 82 def reflexive_(entity) reflexive(entity).cap_first end |
.subjective(entity) ⇒ String Also known as: they, he, she
28 29 30 |
# File 'lib/gamefic/grammar/pronoun.rb', line 28 def subjective(entity) prounoun_map(entity)[:subjective] end |
.subjective_(entity) ⇒ String Also known as: they_, he_, she_
37 38 39 |
# File 'lib/gamefic/grammar/pronoun.rb', line 37 def subjective_(entity) subjective(entity).cap_first end |