Class: String
- Defined in:
- lib/wedge/utilis/blank.rb,
lib/wedge/utilis/element.rb,
lib/wedge/utilis/titleize.rb
Constant Summary collapse
- BLANK_RE =
/\A[[:space:]]*\z/
Instance Method Summary collapse
-
#blank? ⇒ true, false
A string is blank if it’s empty or contains whitespaces only:.
- #is_i? ⇒ Boolean
-
#titleize(opts = {}) ⇒ Object
(also: #titlecase)
Capitalizes most words to create a nicer looking title string.
- #titleize! ⇒ Object (also: #titlecase!)
Instance Method Details
#blank? ⇒ true, false
A string is blank if it’s empty or contains whitespaces only:
''.blank? # => true
' '.blank? # => true
"\t\n\r".blank? # => true
' blah '.blank? # => false
Unicode whitespace is supported:
"\u00a0".blank? # => true
118 119 120 |
# File 'lib/wedge/utilis/blank.rb', line 118 def blank? BLANK_RE === self end |
#is_i? ⇒ Boolean
19 20 21 |
# File 'lib/wedge/utilis/element.rb', line 19 def is_i? self.to_i.to_s == self end |
#titleize(opts = {}) ⇒ Object Also known as: titlecase
Capitalizes most words to create a nicer looking title string.
The list of “small words” which are not capped comes from the New York Times Manual of Style, plus ‘vs’ and ‘v’.
titleize is also aliased as titlecase.
"notes on a scandal" # => "Notes on a Scandal"
"the good german" # => "The Good German"
85 86 87 88 89 90 91 |
# File 'lib/wedge/utilis/titleize.rb', line 85 def titleize(opts={}) # if defined? ActiveSupport # ActiveSupport::Inflector.titleize(self, opts) # else Titleize.titleize(self) # end end |
#titleize! ⇒ Object Also known as: titlecase!
94 95 96 |
# File 'lib/wedge/utilis/titleize.rb', line 94 def titleize! replace(titleize) end |