Method: JSON::Editor::PopUpMenu#append_new_node
- Defined in:
- lib/json/editor.rb
#append_new_node(item) ⇒ Object
Append a new node to the selected Hash or Array.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/json/editor.rb', line 387 def append_new_node(item) if parent = selection.selected parent_type = parent.type case parent_type when 'Hash' key, type, content = ask_for_hash_pair(parent) key or return iter = create_node(parent, 'Key', key) iter = create_node(iter, type, content) toplevel.display_status( "Added a (key, value)-pair to '#{parent_type}'.") window.change when 'Array' type, content = ask_for_element(parent) type or return iter = create_node(parent, type, content) window.change toplevel.display_status("Appendend an element to '#{parent_type}'.") else toplevel.display_status("Cannot append to '#{parent_type}'!") end else type, content = ask_for_element type or return iter = create_node(nil, type, content) window.change end end |