class Sass::Embedded::Host::ValueProtofier

def to_proto(obj)

def to_proto(obj)
  case obj
  when Sass::Value::String
    Sass::EmbeddedProtocol::Value.new(
      string: Sass::EmbeddedProtocol::Value::String.new(
        text: obj.text,
        quoted: obj.quoted?
      )
    )
  when Sass::Value::Number
    Sass::EmbeddedProtocol::Value.new(
      number: Sass::EmbeddedProtocol::Value::Number.new(
        value: obj.value.to_f,
        numerators: obj.numerator_units,
        denominators: obj.denominator_units
      )
    )
  when Sass::Value::Color
    if obj.instance_eval { !defined?(@hue) }
      Sass::EmbeddedProtocol::Value.new(
        rgb_color: Sass::EmbeddedProtocol::Value::RgbColor.new(
          red: obj.red,
          green: obj.green,
          blue: obj.blue,
          alpha: obj.alpha.to_f
        )
      )
    elsif obj.instance_eval { !defined?(@saturation) }
      Sass::EmbeddedProtocol::Value.new(
        hwb_color: Sass::EmbeddedProtocol::Value::HwbColor.new(
          hue: obj.hue.to_f,
          whiteness: obj.whiteness.to_f,
          blackness: obj.blackness.to_f,
          alpha: obj.alpha.to_f
        )
      )
    else
      Sass::EmbeddedProtocol::Value.new(
        hsl_color: Sass::EmbeddedProtocol::Value::HslColor.new(
          hue: obj.hue.to_f,
          saturation: obj.saturation.to_f,
          lightness: obj.lightness.to_f,
          alpha: obj.alpha.to_f
        )
      )
    end
  when Sass::Value::ArgumentList
    Sass::EmbeddedProtocol::Value.new(
      argument_list: Sass::EmbeddedProtocol::Value::ArgumentList.new(
        id: obj.instance_eval { @id },
        contents: obj.contents.map { |element| to_proto(element) },
        keywords: obj.keywords.transform_values { |value| to_proto(value) },
        separator: ListSeparator.to_proto(obj.separator)
      )
    )
  when Sass::Value::List
    Sass::EmbeddedProtocol::Value.new(
      list: Sass::EmbeddedProtocol::Value::List.new(
        contents: obj.contents.map { |element| to_proto(element) },
        separator: ListSeparator.to_proto(obj.separator),
        has_brackets: obj.bracketed?
      )
    )
  when Sass::Value::Map
    Sass::EmbeddedProtocol::Value.new(
      map: Sass::EmbeddedProtocol::Value::Map.new(
        entries: obj.contents.map do |key, value|
          Sass::EmbeddedProtocol::Value::Map::Entry.new(
            key: to_proto(key),
            value: to_proto(value)
          )
        end
      )
    )
  when Sass::Value::Function
    if obj.id
      Sass::EmbeddedProtocol::Value.new(
        compiler_function: Sass::EmbeddedProtocol::Value::CompilerFunction.new(
          id: obj.id
        )
      )
    else
      Sass::EmbeddedProtocol::Value.new(
        host_function: Sass::EmbeddedProtocol::Value::HostFunction.new(
          id: @function_registry.register(obj.callback),
          signature: obj.signature
        )
      )
    end
  when Sass::Value::Boolean
    Sass::EmbeddedProtocol::Value.new(
      singleton: obj.value ? :TRUE : :FALSE
    )
  when Sass::Value::Null
    Sass::EmbeddedProtocol::Value.new(
      singleton: :NULL
    )
  else
    raise Sass::ScriptError, "Unknown Sass::Value #{obj}"
  end
end