Class: String

Overview

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

Direct Known Subclasses

ActiveSupport::JSON::Variable

Instance Method Summary collapse

Methods included from ActiveSupport::CoreExtensions::String::Unicode

#chars, #is_utf8?

Methods included from ActiveSupport::CoreExtensions::String::Iterators

#each_char

Methods included from ActiveSupport::CoreExtensions::String::StartsEndsWith

#ends_with?, #starts_with?

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

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

Methods included from ActiveSupport::CoreExtensions::String::Conversions

#to_date, #to_time

Methods included from ActiveSupport::CoreExtensions::String::Access

#at, #first, #from, #last, #to

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/active_support/core_ext/blank.rb', line 47

def blank?
  empty? || strip.empty?
end

#to_xsObject

XML escaped version of to_s



107
108
109
110
111
# File 'lib/active_support/vendor/builder/xchar.rb', line 107

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