Parent

Class/Module Index [+]

Quicksearch

String

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Public Instance Methods

blank?() click to toggle source

Rails defines this for a number of other classes, including Object see activesupport/lib/active_support/core_ext/object/blank.rb

# File lib/deltacloud/core_ext/string.rb, line 20
def blank?
    self !~ /\S/
end
camelize() click to toggle source

Camelize converts strings to UpperCamelCase

# File lib/deltacloud/drivers/rhevm/rhevm_client.rb, line 505
def camelize
  self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end
pluralize() click to toggle source
# File lib/deltacloud/core_ext/string.rb, line 35
def pluralize
  return self + 'es' if self =~ /ess$/
  return self[0, self.length-1] + "ies" if self =~ /ty$/
  return self if self =~ /data$/
  self + "s"
end
singularize() click to toggle source
# File lib/deltacloud/core_ext/string.rb, line 42
def singularize
  return self.gsub(/es$/, '') if self =~ /sses$/
  self.gsub(/s$/, '')
end
titlecase() click to toggle source

Title case.

"this is a string".titlecase
=> "This Is A String"

CREDIT: Eliazar Parra Copied from facets

# File lib/deltacloud/core_ext/string.rb, line 31
def titlecase
  gsub(/\b\w/){ $`[-1,1] == "'" ? $& : $&.upcase }
end
to_class_name() click to toggle source
# File tests/cimi/features/support/env.rb, line 29
def to_class_name
  to_entity_name.singularize
end
to_collection_uri() click to toggle source
# File tests/cimi/features/support/env.rb, line 37
def to_collection_uri
  self.tr(' ', '_').downcase
end
to_entity_name() click to toggle source
# File tests/cimi/features/support/env.rb, line 33
def to_entity_name
  self.tr(' ', '')
end
to_entity_uri() click to toggle source
# File tests/cimi/features/support/env.rb, line 41
def to_entity_uri
  to_collection_uri.pluralize
end
uncapitalize() click to toggle source
# File lib/deltacloud/core_ext/string.rb, line 60
def uncapitalize
  self[0, 1].downcase + self[1..-1]
end
underscore() click to toggle source
# File lib/deltacloud/core_ext/string.rb, line 47
def underscore
    gsub(/::/, '/').
        gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
        gsub(/([a-z\d])([A-Z])/,'\1_\2').
        tr("-", "_").
        downcase
end
upcase_first() click to toggle source
# File lib/deltacloud/core_ext/string.rb, line 64
def upcase_first
  self[0, 1].upcase + self[1..-1]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.