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
563 564 565 |
# File 'lib/deltacloud.rb', line 563 def camelize self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
- (Object) classify
Create a class name from string
556 557 558 |
# File 'lib/deltacloud.rb', line 556 def classify self.singularize.camelize end |
- (Object) convert
Convert string to float if string value seems like Float
576 577 578 579 |
# File 'lib/deltacloud.rb', line 576 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
582 583 584 |
# File 'lib/deltacloud.rb', line 582 def sanitize self.gsub(/(\W+)/, '_') end |
- (Object) singularize
Strip ‘s’ character from end of string
570 571 572 |
# File 'lib/deltacloud.rb', line 570 def singularize self.gsub(/s$/, '') end |