File: map.rb

package info (click to toggle)
ruby-sassc 2.4.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 368 kB
  • sloc: ruby: 2,277; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 576 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module SassC
  module Script
    module ValueConversion
      class Map < Base
        def to_native
          hash = @value.to_h
          native_map = Native::make_map( hash.size )
          hash.each_with_index do |(key, value), index|
            key   = ValueConversion.to_native key
            value = ValueConversion.to_native value
            Native::map_set_key(   native_map, index, key )
            Native::map_set_value( native_map, index, value )
          end
          return native_map
        end
      end
    end
  end
end