Sha256: 34e5ebeec4cf5748dc6363689ce4be316f7e538b8e21a17ca730ecd18c470b91
Contents?: true
Size: 424 Bytes
Versions: 141
Compression:
Stored size: 424 Bytes
Contents
module Crack module Util def snake_case(str) return str.downcase if str =~ /^[A-Z]+$/ str.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/ return $+.downcase end def to_xml_attributes(hash) hash.map do |k,v| %{#{Crack::Util.snake_case(k.to_s).sub(/^(.{1,1})/) { |m| m.downcase }}="#{v.to_s.gsub('"', '"')}"} end.join(' ') end extend self end end
Version data entries
141 entries across 132 versions & 18 rubygems