Module: Inform::Articles

Included in:
Inform, Parser, Verbs
Defined in:
lib/runtime/articles.rb

Overview

The Articles module Support standard Inform methods for dynamically applying appropriate articles to nouns.

Constant Summary collapse

LowercaseTheSpaceString =
'the '.freeze
LowercaseSomeSpaceString =
'some '.freeze
LowercaseASpaceString =
'a '.freeze

Instance Method Summary collapse

Instance Method Details

#A(obj) ⇒ Object

rubocop: enable Metrics/AbcSize



81
82
83
# File 'lib/runtime/articles.rb', line 81

def A(obj)
  a(obj)&.sentence_case || obj.to_s
end

#a(obj) ⇒ Object

rubocop: disable Metrics/AbcSize



69
70
71
72
73
74
75
76
77
78
# File 'lib/runtime/articles.rb', line 69

def a(obj)
  return Inform::English::NOTHING__TX if obj.nil?
  return PrefaceByArticle(obj, 1) if obj.is_a?(String)
  return obj.to_s unless obj.respond_to?(:has?)
  return obj.to_s if obj.has?(:proper)
  return obj.article + ' ' + obj.to_s if obj.string?(:article)
  return LowercaseSomeSpaceString + obj.to_s if obj.has?(:pluralname)
  # PrefaceByArticle(obj, 1)
  LowercaseASpaceString + obj.to_s
end

#cthatorthose(obj) ⇒ Object



93
# File 'lib/runtime/articles.rb', line 93

def cthatorthose(obj);   CThatorThose(obj);   end

#Cthatorthose(obj) ⇒ Object



91
# File 'lib/runtime/articles.rb', line 91

def Cthatorthose(obj);   CThatorThose(obj);   end

#ctheyreorthats(obj) ⇒ Object



97
# File 'lib/runtime/articles.rb', line 97

def ctheyreorthats(obj); CTheyreorThats(obj); end

#Ctheyreorthats(obj) ⇒ Object



95
# File 'lib/runtime/articles.rb', line 95

def Ctheyreorthats(obj); CTheyreorThats(obj); end

#defart(obj) ⇒ Object



54
55
56
57
58
# File 'lib/runtime/articles.rb', line 54

def defart(obj)
  return theirself(obj) if obj == player
  return hisorher(player, obj) if player.descendants.include?(obj)
  the(obj)
end

#indefart(obj) ⇒ Object



60
61
62
63
64
# File 'lib/runtime/articles.rb', line 60

def indefart(obj)
  return theirself(obj) if obj == player
  return hisorher(player, obj) if player.descendants.include?(obj)
  a(obj)
end

#isorare(obj) ⇒ Object



85
# File 'lib/runtime/articles.rb', line 85

def isorare(obj); IsorAre(obj); end

#itorthem(obj) ⇒ Object



87
# File 'lib/runtime/articles.rb', line 87

def itorthem(obj);       ItorThem(obj);       end

#thatorthose(obj) ⇒ Object



89
# File 'lib/runtime/articles.rb', line 89

def thatorthose(obj);    ThatorThose(obj);    end

#The(obj) ⇒ Object

rubocop: enable Metrics/AbcSize rubocop: enable Metrics/CyclomaticComplexity



48
49
50
51
52
# File 'lib/runtime/articles.rb', line 48

def The(obj)
  return obj.to_s unless obj.respond_to?(:has?)
  return obj.to_s if obj.has?(:proper)
  the(obj).capitalize
end

#the(obj) ⇒ Object

TODO: Add support for on-the-fly indefinite/definite mode differentiation based on the inclusion of the noun (x1) in the pronouns table. rubocop: disable Metrics/AbcSize rubocop: disable Metrics/CyclomaticComplexity



35
36
37
38
39
40
41
42
43
44
# File 'lib/runtime/articles.rb', line 35

def the(obj)
  return Inform::English::NOTHING__TX if obj.nil?
  return PrefaceByArticle(obj, 0) if obj.is_a?(String)
  return obj.to_s unless obj.respond_to?(:has?)
  return obj.to_s if obj.has?(:proper)
  return obj.article + ' ' + obj.to_s if obj.string?(:article)
  return your(obj) if obj.respond_to?(:owner) && obj.owner == player
  # PrefaceByArticle(obj, 1)
  LowercaseTheSpaceString + obj.to_s
end