Top Level Namespace

Defined Under Namespace

Classes: ClassInfo, Converter, MultiConverter, NodeInfo, Session

Instance Method Summary collapse

Instance Method Details

#creation_call(name, class_name, info) ⇒ Object



17
18
19
20
# File 'lib/puer/xibtoti.rb', line 17

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

#inline_js_for(data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/puer/xibtoti.rb', line 4

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

#js_comments_for(text) ⇒ Object



31
32
33
# File 'lib/puer/xibtoti.rb', line 31

def js_comments_for text
 ""  #text.map {|line| line.chomp.empty? ? line : "// #{line}"}.join + "\n"
end

#js_for(nodes) ⇒ Object



27
28
29
# File 'lib/puer/xibtoti.rb', line 27

def js_for(nodes)
  nodes.map {|node| js_sections_for(node)}.flatten.join("\n\n")
end

#js_sections_for(node) ⇒ Object



22
23
24
25
# File 'lib/puer/xibtoti.rb', line 22

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