fluke/devops-service/lib/core_ext/string.rb
2016-01-19 18:11:07 +03:00

27 lines
384 B
Ruby

class String
def present?
!empty?
end
def blank?
empty?
end
# from ActiveSupport
def underscore
gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
def underscore_class
split('::').last.underscore
end
# rough simplification
def pluralize
"#{self}s"
end
end