Sha256: 5eb546d651cdd5b5a91a5daa6593b01b877c1d4ec420666113b90ee3f8b70760
Contents?: true
Size: 845 Bytes
Versions: 3
Compression:
Stored size: 845 Bytes
Contents
$LOAD_PATH.unshift(File.dirname(__FILE__)) require 'session' def inline_js_for(data) case data when Hash '{' + data.map {|k,v| "#{k}:#{inline_js_for(v)}"}.join(',') + '}' when String "'#{data}'" else data.to_s end end def creation_call(name, class_name, info) "var #{name} = #{class_name}({\n" + info.keys.sort.map {|key| "\t#{key}:#{inline_js_for(info[key])}"}.join(",\n") + "\n});" end def js_sections_for(node) [creation_call(node.name, node.node_class.creation_call, node.properties)] + node.subviews.map {|child| [js_sections_for(child), "#{node.name}.add(#{child.name});"]}.flatten end def js_for(nodes) nodes.map {|node| js_sections_for(node)}.flatten.join("\n\n") end def js_comments_for text "" #text.map {|line| line.chomp.empty? ? line : "// #{line}"}.join + "\n" end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
puer-0.0.6 | lib/puer/xibtoti.rb |
puer-0.0.4 | lib/puer/xibtoti.rb |
puer-0.0.3 | lib/puer/xibtoti.rb |