Module: Carta::Util
- Defined in:
- lib/carta/util.rb
Class Method Summary collapse
-
.pad(number) ⇒ Object
Pads a number so that it’s 2 digits wide with leading zeros if needed.
-
.slug(string) ⇒ Object
Takes a string and prepares it for use as a filename or URL.
Class Method Details
.pad(number) ⇒ Object
Pads a number so that it’s 2 digits wide with leading zeros if needed. 1 -> 01
15 16 17 |
# File 'lib/carta/util.rb', line 15 def self.pad(number) sprintf('%02d', number.to_s) end |
.slug(string) ⇒ Object
Takes a string and prepares it for use as a filename or URL. “Hello World!” -> “hello-world”
5 6 7 8 9 10 |
# File 'lib/carta/util.rb', line 5 def self.slug(string) string.downcase .strip .gsub(' ', '-') .gsub(/[^0-9A-z.\-]/, '') end |