Class: Sass::Constant::Literal

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/haml-2.0.4/lib/sass/constant/literal.rb,
lib/gems/haml-2.0.4/lib/sass/constant/literal.rb

Overview

:nodoc:

Direct Known Subclasses

Color, Nil, Number, String

Constant Summary collapse

NUMBER =

The regular expression matching numbers.

/^(-?\d*?\.?)(\d+)([^\d\s]*)$/
COLOR =

The regular expression matching colors.

/^\# (?: [\da-f]{3} | [\da-f]{6} ) | #{html_color_matcher}/ix

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil) ⇒ Literal

Returns a new instance of Literal.



29
30
31
# File 'lib/gems/haml-2.0.4/lib/sass/constant/literal.rb', line 29

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



41
42
43
# File 'lib/gems/haml-2.0.4/lib/sass/constant/literal.rb', line 41

def value
  @value
end

Class Method Details

.parse(value) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/gems/haml-2.0.4/lib/sass/constant/literal.rb', line 18

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

Instance Method Details

#concat(other) ⇒ Object



37
38
39
# File 'lib/gems/haml-2.0.4/lib/sass/constant/literal.rb', line 37

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

#performObject



33
34
35
# File 'lib/gems/haml-2.0.4/lib/sass/constant/literal.rb', line 33

def perform
  self
end