Module: StringExtensions
- Defined in:
- lib/string_extensions.rb
Instance Method Summary collapse
-
#blank? ⇒ Boolean
from Active Support library.
- #remove_internal_spaces ⇒ Object
- #rgb_to_integer ⇒ Object
-
#start_with?(prefix) ⇒ Boolean
from Ruby Facets library.
Instance Method Details
#blank? ⇒ Boolean
from Active Support library
5 6 7 |
# File 'lib/string_extensions.rb', line 5 def blank? self !~ /\S/ end |
#remove_internal_spaces ⇒ Object
17 18 19 |
# File 'lib/string_extensions.rb', line 17 def remove_internal_spaces gsub(/[\n|\r|\s]+/, '') end |
#rgb_to_integer ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/string_extensions.rb', line 21 def rgb_to_integer if self.length == 7 # '#FF00FF' Integer(self.gsub('#', '0x')) else raise "#{self} doesn't seem to be a proper RGB code." end end |
#start_with?(prefix) ⇒ Boolean
from Ruby Facets library
12 13 14 |
# File 'lib/string_extensions.rb', line 12 def start_with?(prefix) self.index(prefix) == 0 end |