This class creates the File pulldown menu.
Create the menu.
# File json/lib/json/editor.rb, line 527
def create
title = MenuItem.new('File')
title.submenu = menu
add_item('New', &method(:new))
add_item('Open', o, &method(:open))
add_item('Open location', l, &method(:open_location))
add_item('Revert', &method(:revert))
add_separator
add_item('Save', s, &method(:save))
add_item('Save As', S, &method(:save_as))
add_separator
add_item('Quit', q, &method(:quit))
title
end
Clear the model and filename, but ask to save the JSON document, if unsaved changes have occured.
# File json/lib/json/editor.rb, line 490
def new(item)
window.clear
end
Open a file and load it into the editor. Ask to save the JSON document first, if unsaved changes have occured.
# File json/lib/json/editor.rb, line 496
def open(item)
window.file_open
end
# File json/lib/json/editor.rb, line 500
def open_location(item)
window.location_open
end
Quit the editor, after asking to save any unsaved changes first.
# File json/lib/json/editor.rb, line 522
def quit(item)
window.quit
end
Revert the current JSON document in the editor to the saved version.
# File json/lib/json/editor.rb, line 505
def revert(item)
window.instance_eval do
@filename and file_open(@filename)
end
end
Save the current JSON document.
# File json/lib/json/editor.rb, line 512
def save(item)
window.file_save
end
Save the current JSON document under the given filename.
# File json/lib/json/editor.rb, line 517
def save_as(item)
window.file_save_as
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.