class Phlex::SGML
def __styles__(styles)
def __styles__(styles) case styles when Array, Set styles.filter_map do |s| case s when String if s == "" || s.end_with?(";") s else "#{s};" end when Phlex::SGML::SafeObject value = s.to_s value.end_with?(";") ? value : "#{value};" when Hash next __styles__(s) when nil next nil else raise Phlex::ArgumentError.new("Invalid style: #{s.inspect}.") end end.join(" ") when Hash buffer = +"" i = 0 styles.each do |k, v| prop = case k when String k when Symbol k.name.tr("_", "-") else raise Phlex::ArgumentError.new("Style keys should be Strings or Symbols.") end value = case v when String v when Symbol v.name.tr("_", "-") when Integer, Float, Phlex::SGML::SafeObject v.to_s when nil nil else raise Phlex::ArgumentError.new("Invalid style value: #{v.inspect}") end if value if i == 0 buffer << prop << ": " << value << ";" else buffer << " " << prop << ": " << value << ";" end end i += 1 end buffer end end