Sha256: 46fdffc9c0d60e8ec3fe8d6f8242149c7fcd2ca9b6085732478f67604f2fb648

Contents?: true

Size: 945 Bytes

Versions: 7

Compression:

Stored size: 945 Bytes

Contents

require 'sass/script/literal'

module Sass::Script
  class String < Literal # :nodoc:
    INTERPOLATION = /(^|[^\\])\#\{([^}]*)\}/
    #TODO pass line & char context to perform
    def perform(environment)
      interpolated = @value.gsub(INTERPOLATION) do |match|
        "#{$1}#{Sass::Script.resolve($2, 0, 0, environment)}"
      end
      Sass::Script::String.new(interpolated)
    end

    def plus(other)
      Sass::Script::String.new(self.to_s + other.to_s)
    end

    def minus(other)
      Sass::Script::String.new("#{self.to_s}-#{other.to_s}")
    end

    def unary_minus
      Sass::Script::String.new("-#{self.to_s}")
    end

    def div(other)
      Sass::Script::String.new("#{self.to_s}/#{other.to_s}")
    end

    def unary_div
      Sass::Script::String.new("/#{self.to_s}")
    end

    def funcall(other)
      Sass::Script::String.new("#{self.to_s}(#{other.to_s})")
    end

    def to_s
      @value
    end
  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
jwhitmire-haml-2.1.0.1 lib/sass/script/string.rb
jwhitmire-haml-2.1.0.2 lib/sass/script/string.rb
jwhitmire-haml-2.1.0.3 lib/sass/script/string.rb
wireframe-haml-2.1.0 lib/sass/script/string.rb
wireframe-haml-2.1.1 lib/sass/script/string.rb
merbjedi-haml-2.1.0 lib/sass/script/string.rb
spree-0.8.0 vendor/gems/haml-2.1.0/lib/sass/script/string.rb