Class: String

Inherits:
Object show all
Includes:
ActiveSupport::CoreExtensions::String::Inflections
Defined in:
lib/active_support/core_ext/blank.rb,
lib/active_support/core_ext/string.rb,
lib/active_support/vendor/builder-2.1.2/builder/xchar.rb

Overview

Enhance the String class with a XML escaped character version of to_s.

Instance Method Summary collapse

Methods included from ActiveSupport::CoreExtensions::String::Inflections

#camelize, #classify, #constantize, #dasherize, #demodulize, #humanize, #parameterize, #pluralize, #singularize, #tableize, #titleize, #underscore

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/active_support/core_ext/blank.rb', line 49

def blank?
  self !~ /\S/
end

#to_xsObject

XML escaped version of to_s



110
111
112
113
114
# File 'lib/active_support/vendor/builder-2.1.2/builder/xchar.rb', line 110

def to_xs
  unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8
rescue
  unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
end