Skip to content

Instantly share code, notes, and snippets.

@octosteve
Created October 29, 2013 02:28
Show Gist options
  • Save octosteve/7208248 to your computer and use it in GitHub Desktop.
Save octosteve/7208248 to your computer and use it in GitHub Desktop.
Solution from conditionals class
class UpvoteCalculator
attr_reader :story, :category
def initialize story, category
@story = story
@category = category
end
def upvotes
upvotes = 1
downcased_story = @story.downcase
if downcased_story.include? 'cats'
upvotes *= 5
elsif downcased_story.include? 'bacon'
upvotes *= 8
end
if @category.downcase.include? 'food'
upvotes *= 3
end
upvotes
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment