Method: JSON::Editor::MainWindow#load_file

Defined in:
lib/json/editor.rb

#load_file(filename) ⇒ Object

Load the file named filename into the editor as a JSON document.



1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
# File 'lib/json/editor.rb', line 1246

def load_file(filename)
  if filename
    if File.directory?(filename)
      Editor.error_dialog(self, "Try to select a JSON file!")
      nil
    else
      @filename = filename
      if data = read_data(filename)
        toplevel.display_status("Loaded data from '#@filename'.")
      end
      display_title
      data
    end
  end
end