Sha256: b59f19c79c05540fbf49f22a4622724a37eb783d2ce5633edcb32202bb767ad7
Contents?: true
Size: 804 Bytes
Versions: 2
Compression:
Stored size: 804 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) "#{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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xibtoti-0.0.2 | lib/xibtoti.rb |
xibtoti-0.0.1 | lib/xibtoti.rb |