Class: Sass::Script::Value::Map 
  - Inherits:
-  Base  - Object
- Base
- Sass::Script::Value::Map
 show all
- Defined in:
- /Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb
Overview
  A SassScript object representing a map from keys to values. Both keys and values can be any SassScript object.
      
 Instance Attribute Summary (collapse)
  Attributes inherited from Base
 #options, #source_range
  Instance Method Summary (collapse) 
  Methods inherited from Base
 #==, #_perform, #assert_int!, #div, #eql?, #minus, #neq, #null?, #plus, #single_eq, #to_bool, #to_i, #unary_div, #unary_minus, #unary_not, #unary_plus
  Constructor Details
   - (Map) initialize(hash) 
   | 
14
15
16 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 14
def initialize(hash)
  super(Sass::Util.ordered_hash(hash))
end | 
 
      Instance Attribute Details
    - (Hash<Node, Node>) value  Also known as: to_h  
  The Ruby hash containing the contents of this map.
       | 
8
9
10 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 8
def value
  @value
end | 
 
      Instance Method Details
   - eq(other) 
   | 
42
43
44 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 42
def eq(other)
  Bool.new(other.is_a?(Map) && value == other.value)
end | 
 
     - hash 
  | 
46
47
48 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 46
def hash
  @hash ||= value.hash
end | 
 
     - options=(options) 
   | 
19
20
21
22
23
24
25 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 19
def options=(options)
  super
  value.each do |k, v|
    k.options = options
    v.options = options
  end
end | 
 
     - separator 
   | 
28
29
30 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 28
def separator
  :comma unless value.empty?
end | 
 
     - to_a 
   | 
33
34
35
36
37
38
39 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 33
def to_a
  value.map do |k, v|
    list = List.new([k, v], :space)
    list.options = options
    list
  end
end | 
 
     - to_s(opts = {}) 
   | 
51
52
53 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 51
def to_s(opts = {})
  raise Sass::SyntaxError.new("#{inspect} isn't a valid CSS value.")
end | 
 
     - to_sass(opts = {}) Also known as: inspect  
  | 
55
56
57
58
59
60
61
62
63
64
65
66
67 | # File '/Users/ceppstei/Projects/sass-lang/.sass/lib/sass/script/value/map.rb', line 55
def to_sass(opts = {})
  return "()" if value.empty?
  to_sass = lambda do |value|
    if value.is_a?(List) && value.separator == :comma
      "(#{value.to_sass(opts)})"
    else
      value.to_sass(opts)
    end
  end
  "(#{value.map {|(k, v)| "#{to_sass[k]}: #{to_sass[v]}"}.join(', ')})"
end |