Module: SassC::Script::ValueConversion
- Defined in:
- lib/sassc/script/value_conversion.rb,
lib/sassc/script/value_conversion/base.rb,
lib/sassc/script/value_conversion/color.rb,
lib/sassc/script/value_conversion/string.rb
Defined Under Namespace
Classes: Base, Color, String
Class Method Summary
collapse
Class Method Details
.from_native(native_value, options) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sassc/script/value_conversion.rb', line 4
def self.from_native(native_value, options)
case value_tag = Native.value_get_tag(native_value)
when :sass_null
when :sass_string
value = Native.string_get_value(native_value)
type = Native.string_get_type(native_value)
argument = Script::String.new(value, type)
argument
when :sass_color
red, green, blue, alpha = Native.color_get_r(native_value), Native.color_get_g(native_value), Native.color_get_b(native_value), Native.color_get_a(native_value)
argument = Script::Color.new([red, green, blue, alpha])
argument.options = options
argument
else
raise UnsupportedValue.new("Sass argument of type #{value_tag} unsupported")
end
end
|
.to_native(value) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/sassc/script/value_conversion.rb', line 26
def self.to_native(value)
case value_name = value.class.name.split("::").last
when "String"
String.new(value).to_native
when "Color"
Color.new(value).to_native
else
raise UnsupportedValue.new("Sass return type #{value_name} unsupported")
end
end
|