Skip to content

Instantly share code, notes, and snippets.

@r00k
Created July 20, 2012 14:40
Show Gist options
  • Save r00k/3151070 to your computer and use it in GitHub Desktop.
Save r00k/3151070 to your computer and use it in GitHub Desktop.
class HumanizedTagContext
def initialize(game, context)
@game = game
@context = context
end
def to_s
case @context
when "location"
"Where #{tense(@context)} the game?"
when "wear"
"What #{tense(@context)}?"
when "who"
"Who #{tense(@context)}?"
else
@context
end
end
def for_tag(tag, team = nil)
if team.nil? then
case @context
when "location"
"When you watch a game @ \"#{tag.name.capitalize}\""
when "wear"
"When you wear your \"#{tag.name.titleize}\""
when "who"
"When you're with \"#{tag.name.titleize}\""
else
tag
end
else
case @context
when "location"
"When you watch a #{team.nickname} game @ \"#{tag.name.capitalize}\""
when "wear"
"When you wear your \"#{tag.name.titleize}\" for a #{team.nickname} game"
when "who"
"When you're with \"#{tag.name.titleize}\" for a #{team.nickname} game"
else
tag
end
end
end
private
def tense(verb)
present_tense = @game.nil? || [email protected]? ? true : false
if present_tense then
case verb
when "location"
"are you watching"
when "wear"
"are you going to wear"
when "who"
"are you going to be with"
else
@context
end
else
case verb
when "location"
"did you watch"
when "wear"
"did you wear"
when "who"
"were you with"
else
@context
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment