Class: Gamefic::Grammar::Pronouns

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/grammar/pronouns.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Pronouns

Returns a new instance of Pronouns.



6
7
8
# File 'lib/gamefic/grammar/pronouns.rb', line 6

def initialize object
  @object = object
end

Class Method Details

.get_pronoun_set(obj) ⇒ Array<String>

Get a an array of pronouns based on the person, gender, and plurality of the provided object.

Parameters:

  • obj

    An object that responds to #person, #gender, and #plural

Returns:



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/gamefic/grammar/pronouns.rb', line 71

def self.get_pronoun_set(obj)
  set = Pronouns.sets["#{obj.person}"]
  if set.nil?
    set = Pronouns.sets["#{obj.person}:#{obj.plural? ? 'plural' : 'singular'}"]
  end
  if set.nil?
    set = Pronouns.sets["#{obj.person}:#{obj.plural? ? 'plural' : 'singular'}:#{obj.gender}"]
  end
  if set.nil?
    raise "Pronoun set could not be determined"
  end
  set
end

.setsObject

TODO Consider implementing method_missing to determine correct pronoun from example, e.g., “he” would change to “she” for female entities



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/gamefic/grammar/pronouns.rb', line 87

def self.sets
  if @sets.nil?
    @sets = {}
    @sets["1:singular"] = ["I", "me", "my", "myself"]
    @sets["2:singular"] = ["you", "you", "your", "yourself"]
    @sets["3:singular:male"] = ["he", "him", "his", "himself"]
    @sets["3:singular:female"] = ["she", "her", "her", "herself"]
    # "other" refers to a person or living being that is neither

    # male or female or for whom gender is unspecified. It's

    # typically used to avoid referring to a person as "it."

    @sets["3:singular:other"] = ["they", "them", "their", "themselves"]
    @sets["3:singular:neutral"] = ["it", "it", "its", "itself"]
    @sets["1:plural"] = ["we", "us", "our", "ourselves"]
    @sets["2:plural"] = ["you", "you", "your", "yourselves"]
    @sets["3:plural"] = ["they", "them", "their", "themselves"]
  end
  @sets
end

Instance Method Details

#objString

Get the objective pronoun (me, them, us, etc.)

Returns:



20
21
22
# File 'lib/gamefic/grammar/pronouns.rb', line 20

def obj
  Pronouns.get_pronoun_set(@object)[1]
end

#ObjString

Get the capitalized objective pronoun

Returns:



48
49
50
# File 'lib/gamefic/grammar/pronouns.rb', line 48

def Obj
  obj.cap_first
end

#possString

Get the possessive pronoun (my, your, our, etc.)

Returns:



27
28
29
# File 'lib/gamefic/grammar/pronouns.rb', line 27

def poss
  Pronouns.get_pronoun_set(@object)[2]
end

#PossString

Get the capitalized possessive pronoun

Returns:



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

def Poss
  poss.cap_first
end

#reflexString

Get the reflexive pronoun (myself, yourself, etc.)

Returns:



34
35
36
# File 'lib/gamefic/grammar/pronouns.rb', line 34

def reflex
  Pronouns.get_pronoun_set(@object)[3]
end

#ReflexString

Get the capitalized reflexive pronoun

Returns:



62
63
64
# File 'lib/gamefic/grammar/pronouns.rb', line 62

def Reflex
  reflex.cap_first
end

#SubjString

Get the capitalized subjective pronoun

Returns:



41
42
43
# File 'lib/gamefic/grammar/pronouns.rb', line 41

def Subj
  subj.cap_first
end

#subjString

Get the subjective pronoun (I, you, we, etc.)

Returns:



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

def subj
  Pronouns.get_pronoun_set(@object)[0]
end