Class: String
- Includes:
- ActiveSupport::CoreExtensions::String::Access, ActiveSupport::CoreExtensions::String::Behavior, ActiveSupport::CoreExtensions::String::Conversions, ActiveSupport::CoreExtensions::String::Filters, ActiveSupport::CoreExtensions::String::Inflections, ActiveSupport::CoreExtensions::String::Iterators, ActiveSupport::CoreExtensions::String::Multibyte, ActiveSupport::CoreExtensions::String::StartsEndsWith
- Defined in:
- lib/active_support/core_ext/string.rb,
lib/active_support/json/encoders/string.rb,
lib/active_support/core_ext/object/blank.rb,
lib/active_support/core_ext/string/bytesize.rb,
lib/active_support/core_ext/string/output_safety.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.
Direct Known Subclasses
ActiveSupport::JSON::Variable, ActiveSupport::ModelName, ActiveSupport::SafeBuffer, ActiveSupport::StringInquirer
Instance Method Summary collapse
-
#as_json(options = nil) ⇒ Object
:nodoc:.
- #as_str ⇒ Object
- #blank? ⇒ Boolean
- #html_safe ⇒ Object
- #html_safe? ⇒ Boolean
-
#to_json(options = nil) ⇒ Object
:nodoc:.
-
#to_xs ⇒ Object
XML escaped version of to_s.
Methods included from ActiveSupport::CoreExtensions::String::Multibyte
Methods included from ActiveSupport::CoreExtensions::String::Behavior
Methods included from ActiveSupport::CoreExtensions::String::Iterators
Methods included from ActiveSupport::CoreExtensions::String::StartsEndsWith
append_features, #ends_with?, #starts_with?
Methods included from ActiveSupport::CoreExtensions::String::Inflections
#camelize, #classify, #constantize, #dasherize, #demodulize, #foreign_key, #humanize, #parameterize, #pluralize, #singularize, #tableize, #titleize, #underscore
Methods included from ActiveSupport::CoreExtensions::String::Filters
Methods included from ActiveSupport::CoreExtensions::String::Conversions
#ord, #to_date, #to_datetime, #to_time
Methods included from ActiveSupport::CoreExtensions::String::Access
#at, #first, #from, #last, #to
Instance Method Details
#as_json(options = nil) ⇒ Object
:nodoc:
6 7 8 |
# File 'lib/active_support/json/encoders/string.rb', line 6 def as_json( = nil) #:nodoc: self end |
#as_str ⇒ Object
90 91 92 |
# File 'lib/active_support/core_ext/string/output_safety.rb', line 90 def as_str self end |
#blank? ⇒ Boolean
67 68 69 |
# File 'lib/active_support/core_ext/object/blank.rb', line 67 def blank? self !~ /\S/ end |
#html_safe ⇒ Object
94 95 96 |
# File 'lib/active_support/core_ext/string/output_safety.rb', line 94 def html_safe ActiveSupport::SafeBuffer.new(self) end |
#html_safe? ⇒ Boolean
98 99 100 |
# File 'lib/active_support/core_ext/string/output_safety.rb', line 98 def html_safe? false end |
#to_json(options = nil) ⇒ Object
:nodoc:
2 3 4 |
# File 'lib/active_support/json/encoders/string.rb', line 2 def to_json( = nil) #:nodoc: ActiveSupport::JSON::Encoding.escape(self) end |
#to_xs ⇒ Object
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 |