File: list.rb

package info (click to toggle)
ruby-sassc 2.4.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 368 kB
  • sloc: ruby: 2,277; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 606 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
22
23
24
25
# frozen_string_literal: true

module SassC
  module Script
    module ValueConversion
      SEPARATORS = {
        space: :sass_space,
        comma: :sass_comma
      }

      class List < Base
        def to_native
          list = @value.to_a
          sep = SEPARATORS.fetch(@value.separator)
          native_list = Native::make_list(list.size, sep)
          list.each_with_index do |item, index|
            native_item = ValueConversion.to_native(item)
            Native::list_set_value(native_list, index, native_item)
          end
          native_list
        end
      end
    end
  end
end