Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/deltacloud.rb
Instance Method Summary (collapse)
-
- (Object) camelize
Camelize converts strings to UpperCamelCase.
-
- (Object) classify
Create a class name from string.
-
- (Object) convert
Convert string to float if string value seems like Float.
-
- (Object) sanitize
Simply converts whitespaces and - symbols to ‘_’ which is safe for Ruby.
-
- (Object) singularize
Strip ‘s’ character from end of string.
Instance Method Details
- (Object) camelize
Camelize converts strings to UpperCamelCase
499 500 501 |
# File 'lib/deltacloud.rb', line 499 def camelize self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
- (Object) classify
Create a class name from string
492 493 494 |
# File 'lib/deltacloud.rb', line 492 def classify self.singularize.camelize end |
- (Object) convert
Convert string to float if string value seems like Float
512 513 514 515 |
# File 'lib/deltacloud.rb', line 512 def convert return self.to_f if self.strip =~ /^([\d\.]+$)/ self end |
- (Object) sanitize
Simply converts whitespaces and - symbols to ‘_’ which is safe for Ruby
518 519 520 |
# File 'lib/deltacloud.rb', line 518 def sanitize self.gsub(/(\W+)/, '_') end |
- (Object) singularize
Strip ‘s’ character from end of string
506 507 508 |
# File 'lib/deltacloud.rb', line 506 def singularize self.gsub(/s$/, '') end |