Module: Inform::Parser

Includes:
StoryTeller::Articles
Defined in:
lib/story_teller/articles.rb

Overview

Re-open the Inform::Parser module

Constant Summary collapse

VowelsOrHiPattern =
%r{^([aeiou]|hi).+}.freeze

Constants included from StoryTeller::Articles

StoryTeller::Articles::LowercaseASpaceString, StoryTeller::Articles::LowercaseSomeSpaceString, StoryTeller::Articles::LowercaseTheSpaceString

Instance Method Summary collapse

Methods included from StoryTeller::Articles

#A, #Cthatorthose, #Ctheyreorthats, #The, #a, #cthatorthose, #ctheyreorthats, #defart, #indefart, #isorare, #itorthem, #thatorthose, #the

Instance Method Details

#PrefaceByArticle(o, _acode, pluralise = false, capitalise = false) ⇒ Object

TODO: Figure out why this isn’t being called by #a(obj) above. rubocop: disable Metrics/AbcSize rubocop: disable Metrics/CyclomaticComplexity rubocop: disable Metrics/MethodLength rubocop: disable Metrics/PerceivedComplexity



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/story_teller/articles.rb', line 116

def PrefaceByArticle(o, _acode, pluralise = false, capitalise = false)
  log.info "wtf1 #{self.class}##{__method__}" # TODO: Remove
  if (obj_articles = o.&:articles) && obj_articles.respond_to?(:[])
    return obj_articles[acode] unless obj_articles[acode].nil?
    return if pluralise
  end
  return if pluralise
  if VowelsOrHiPattern.match?(o.to_s)
    return "an #{o}".sentence_case if capitalise
    "an #{o}"
  else
    return "a #{o}".sentence_case if capitalise
    "a #{o}"
  end
end