class String
Constants
- ENCODINGS
Public Instance Methods
blank?()
click to toggle source
# File lib/core/string.rb, line 26 def blank? self !~ /[^[:space:]]/ end
camelize()
click to toggle source
# File lib/core/string.rb, line 6 def camelize gsub(/(\-|_)+([a-z])?/){|m| $2 ? $2.upcase : ''} end
capitalize()
click to toggle source
# File lib/core/string.rb, line 14 def capitalize self[0].upcase + slice(1, size) end
constantize()
click to toggle source
# File lib/core/string.rb, line 30 def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end
dasherize()
click to toggle source
# File lib/core/string.rb, line 10 def dasherize underscore.gsub('_', '-') end
ends_with?(substr)
click to toggle source
# File lib/core/string.rb, line 22 def ends_with?(substr) rindex(substr) == size - substr.size end
starts_with?(substr)
click to toggle source
# File lib/core/string.rb, line 18 def starts_with?(substr) index(substr) == 0 end
to_data(encoding=nil)
click to toggle source
# File lib/core/string.rb, line 41 def to_data(encoding=nil) dataUsingEncoding ENCODINGS[encoding] || NSUTF8StringEncoding end
underscore()
click to toggle source
# File lib/core/string.rb, line 2 def underscore gsub(/([a-z\d])([A-Z]+)/, '\1_\2').gsub('-', '_').downcase end