class Sass::Script::Value::String
A SassScript object representing a CSS string or a CSS identifier.
Attributes
type[R]
value[R]
The Ruby value of the string.
@return [String]
Public Class Methods
new(value, type = :identifier)
click to toggle source
Creates a new string.
@param value [String] See {#value} @param type [Symbol] See {#type}
Calls superclass method
Sass::Script::Value::Base.new
# File lib/sass/script/value/string.rb, line 20 def initialize(value, type = :identifier) super(value) @type = type end
Public Instance Methods
plus(other)
click to toggle source
@see Value#plus
# File lib/sass/script/value/string.rb, line 26 def plus(other) other_str = other.is_a?(Sass::Script::Value::String) ? other.value : other.to_s Sass::Script::Value::String.new(value + other_str, type) end
to_s(opts = {})
click to toggle source
@see Value#to_s
# File lib/sass/script/value/string.rb, line 32 def to_s(opts = {}) if @type == :identifier return @value.gsub(/\n\s*/, " ") end return "\"#{value.gsub('"', "\\\"")}\"" if opts[:quote] == %q{"} return "'#{value.gsub("'", "\\'")}'" if opts[:quote] == %q{'} return "\"#{value}\"" unless value.include?('"') return "'#{value}'" unless value.include?("'") "\"#{value.gsub('"', "\\\"")}\"" # ' end
to_sass(opts = {})
click to toggle source
@see Value#to_sass
# File lib/sass/script/value/string.rb, line 45 def to_sass(opts = {}) to_s end