Module: StoryTeller::Articles
- Included in:
- Inform::Parser, Inform::Verbs, Builtins
- Defined in:
- lib/story_teller/articles.rb
Overview
The Articles module Support standard StoryTeller methods for dynamically applying appropriate articles to nouns.
Constant Summary collapse
- LowercaseTheSpaceString =
'the '.freeze
- LowercaseSomeSpaceString =
'some '.freeze
- LowercaseASpaceString =
'a '.freeze
Instance Method Summary collapse
-
#a(obj) ⇒ Object
rubocop: disable Metrics/AbcSize.
-
#A(obj) ⇒ Object
rubocop: enable Metrics/AbcSize.
- #Cthatorthose(obj) ⇒ Object
- #cthatorthose(obj) ⇒ Object
- #Ctheyreorthats(obj) ⇒ Object
- #ctheyreorthats(obj) ⇒ Object
- #defart(obj) ⇒ Object
- #indefart(obj) ⇒ Object
- #isorare(obj) ⇒ Object
- #itorthem(obj) ⇒ Object
- #thatorthose(obj) ⇒ Object
-
#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.
-
#The(obj) ⇒ Object
rubocop: enable Metrics/AbcSize rubocop: enable Metrics/CyclomaticComplexity.
Instance Method Details
#a(obj) ⇒ Object
rubocop: disable Metrics/AbcSize
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/story_teller/articles.rb', line 70 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 |
#A(obj) ⇒ Object
rubocop: enable Metrics/AbcSize
82 83 84 |
# File 'lib/story_teller/articles.rb', line 82 def A(obj) a(obj)&.sentence_case || obj.to_s end |
#Cthatorthose(obj) ⇒ Object
92 |
# File 'lib/story_teller/articles.rb', line 92 def Cthatorthose(obj); CThatorThose(obj); end |
#cthatorthose(obj) ⇒ Object
94 |
# File 'lib/story_teller/articles.rb', line 94 def cthatorthose(obj); CThatorThose(obj); end |
#Ctheyreorthats(obj) ⇒ Object
96 |
# File 'lib/story_teller/articles.rb', line 96 def Ctheyreorthats(obj); CTheyreorThats(obj); end |
#ctheyreorthats(obj) ⇒ Object
98 |
# File 'lib/story_teller/articles.rb', line 98 def ctheyreorthats(obj); CTheyreorThats(obj); end |
#defart(obj) ⇒ Object
55 56 57 58 59 |
# File 'lib/story_teller/articles.rb', line 55 def defart(obj) return theirself(obj) if obj == player return hisorher(player, obj) if player.descendants.include?(obj) the(obj) end |
#indefart(obj) ⇒ Object
61 62 63 64 65 |
# File 'lib/story_teller/articles.rb', line 61 def indefart(obj) return theirself(obj) if obj == player return hisorher(player, obj) if player.descendants.include?(obj) a(obj) end |
#isorare(obj) ⇒ Object
86 |
# File 'lib/story_teller/articles.rb', line 86 def isorare(obj); IsorAre(obj); end |
#itorthem(obj) ⇒ Object
88 |
# File 'lib/story_teller/articles.rb', line 88 def itorthem(obj); ItorThem(obj); end |
#thatorthose(obj) ⇒ Object
90 |
# File 'lib/story_teller/articles.rb', line 90 def thatorthose(obj); ThatorThose(obj); 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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/story_teller/articles.rb', line 36 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 |
#The(obj) ⇒ Object
rubocop: enable Metrics/AbcSize rubocop: enable Metrics/CyclomaticComplexity
49 50 51 52 53 |
# File 'lib/story_teller/articles.rb', line 49 def The(obj) return obj.to_s unless obj.respond_to?(:has?) return obj.to_s if obj.has?(:proper) the(obj).capitalize end |