Skip to content

Instantly share code, notes, and snippets.

View aniki21's full-sized avatar

Paul C aniki21

  • Dundee, UK
View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

# Count syllables in a word
# Based on this StackOverflow answer by Pesto:
# http://stackoverflow.com/a/1272072/245447
def syllable_count(word)
word = word.downcase
return 1 if word.length <= 3
word.sub!(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/, '')
word.sub!(/^y/, '')
word.scan(/[aeiouy]{1,2}/).size
def roll(_roll = "")
# Roll a d6 by default if nothing else is specified
if roll == ""
return rand(6) + 1
end
dice,mod = _roll.split("+").map(&:strip)
count,sides = dice.split("d").map(&:strip)
total = 0