Chronicles of Darkness grimoire-Artifact PDF https://git.lain.church/TheStranjer/ShardsOfPower
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
869B

  1. class String
  2. PUNCTUATION_MARKS = [".", "!", "?"]
  3. def titleize
  4. gsub(/\w+/i) do |match|
  5. ret = match.downcase
  6. ret[0] = ret[0].upcase
  7. ret
  8. end
  9. end
  10. def titleize!
  11. replace titleize
  12. end
  13. def punctuated?
  14. PUNCTUATION_MARKS.include?(self[-1])
  15. end
  16. def unpunctuated?
  17. !punctuated?
  18. end
  19. end
  20. class Integer
  21. def to_dots
  22. "•" * self
  23. end
  24. end
  25. class Array
  26. def to_list(separator: nil)
  27. separator = "and" if separator.nil?
  28. if self.length == 0
  29. nil
  30. elsif self.length == 1
  31. self.first
  32. elsif self.length == 2
  33. "#{self.first} #{separator} #{self.last}"
  34. else
  35. ret = clone
  36. ret[ret.length - 1] = "#{separator} #{ret[ret.length - 1]}"
  37. ret.join(", ")
  38. end
  39. end
  40. def to_arcanum_with_dots
  41. "#{self[0].to_s.titleize} #{self[1].to_dots}"
  42. end
  43. end