2019-05-27 15:02:07 -04:00
|
|
|
class String
|
|
|
|
def titleize
|
|
|
|
gsub(/\w+/i) do |match|
|
|
|
|
ret = match.downcase
|
|
|
|
ret[0] = ret[0].upcase
|
|
|
|
ret
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def titleize!
|
|
|
|
replace titleize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Integer
|
|
|
|
def to_dots
|
|
|
|
"•" * self
|
|
|
|
end
|
2019-05-28 01:53:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class Array
|
|
|
|
def to_list(separator: nil)
|
|
|
|
if self.length == 0
|
|
|
|
nil
|
|
|
|
elsif self.length == 1
|
|
|
|
self.first
|
|
|
|
elsif self.length == 2
|
|
|
|
"#{self.first} #{separator} #{self.last}"
|
|
|
|
else
|
|
|
|
ret = clone
|
|
|
|
ret[ret.length - 1] = "#{separator ? separator : "and"} #{ret[ret.length - 1]}"
|
|
|
|
ret.join(", ")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_arcanum_with_dots
|
|
|
|
"#{self[0].to_s.titleize} #{self[1].to_dots}"
|
|
|
|
end
|
2019-05-27 15:02:07 -04:00
|
|
|
end
|