Class: Sass::Script::Lexer

Inherits:
Object
  • Object
show all
Defined in:
lib/scss_lint/sass/script.rb

Overview

Redefine some of the lexer helpers in order to store the original string with the created object so that the original string can be inspected rather than a typically normalized version.

Instance Method Summary collapse

Instance Method Details

#colorObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/scss_lint/sass/script.rb', line 6

def color
  return unless color_string = scan(REGULAR_EXPRESSIONS[:color])

  unless [4, 7].include?(color_string.length)
    raise ::Sass::SyntaxError,
          "Colors must have either three or six digits: '#{color_string}'"
  end

  [:color, Value::Color.from_string(color_string)]
end

#numberObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/scss_lint/sass/script.rb', line 17

def number
  return unless scan(REGULAR_EXPRESSIONS[:number])
  value = @scanner[2] ? @scanner[2].to_f : @scanner[3].to_i
  value = -value if @scanner[1]

  number = Value::Number.new(value, Array(@scanner[4])).tap do |num|
    num.original_string = @scanner[0]
  end
  [:number, number]
end