Sha256: 1c5adebab9fb2905726fa6db3eb2c3afd1239cf0646e2ed3b2dea86bc5bc6cf7

Contents?: true

Size: 1.17 KB

Versions: 32

Compression:

Stored size: 1.17 KB

Contents

# Let the subclasses see the superclass
module Sass::Constant; class Literal; end; end; # :nodoc:

require 'sass/constant/string'
require 'sass/constant/number'
require 'sass/constant/color'
require 'sass/constant/nil'

class Sass::Constant::Literal # :nodoc:
  # The regular expression matching numbers.
  NUMBER  = /^(-?\d*?\.?)(\d+)([^\d\s]*)$/

  html_color_matcher = Sass::Constant::Color::HTML4_COLORS.keys.map { |c| "^#{c}$" }.join '|'

  # The regular expression matching colors.
  COLOR = /^\# (?: [\da-f]{3} | [\da-f]{6} ) | #{html_color_matcher}/ix

  def self.parse(value)
    case value
    when NUMBER
      Sass::Constant::Number.new(value)
    when COLOR
      Sass::Constant::Color.new(value)
    else
      Sass::Constant::String.new(value)
    end
  end

  def initialize(value = nil)
    self.parse(value) if value
  end

  def perform
    self
  end

  def concat(other)
    Sass::Constant::String.from_value("#{self.to_s} #{other.to_s}")
  end

  attr_reader :value

  protected

  def self.filter_value(value)
    value
  end

  def self.from_value(value)
    instance = self.new
    instance.instance_variable_set('@value', self.filter_value(value))
    instance
  end
end

Version data entries

32 entries across 32 versions & 5 rubygems

Version Path
radiantcms-couchrest_model-0.2.4 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.2.2 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.2.1 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.2 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.1.9 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.1.8 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.1.7 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.1.6 vendor/plugins/haml/lib/sass/constant/literal.rb
radiantcms-couchrest_model-0.1.5 vendor/plugins/haml/lib/sass/constant/literal.rb
radiant-0.7.2 vendor/plugins/haml/lib/sass/constant/literal.rb
radiant-0.8.2 vendor/plugins/haml/lib/sass/constant/literal.rb
radiant-0.9.0.rc2 vendor/plugins/haml/lib/sass/constant/literal.rb
radiant-rc-0.9.0 vendor/plugins/haml/lib/sass/constant/literal.rb
radiant-0.8.1 vendor/plugins/haml/lib/sass/constant/literal.rb
haml-2.0.10 lib/sass/constant/literal.rb
haml-2.0.4 lib/sass/constant/literal.rb
haml-2.0.6 lib/sass/constant/literal.rb
haml-2.0.2 lib/sass/constant/literal.rb
haml-2.0.7 lib/sass/constant/literal.rb
haml-2.0.1 lib/sass/constant/literal.rb