[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-glib-filemanip

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2009年 2月 2日 (月) 23:16:01 JST


-------------------------
REMOTE_ADDR = 74.15.84.244
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-glib-filemanip
-------------------------
@@ -1,4 +1,4 @@
-= GLib Short Tutorial
+= GLib Short Introduction
 {{link "tut-gtk2-glib-timers", "tut-gtk2-glib", "tut-gtk", "tut-gtk2-glib-mainloop" }}
 
 == File Manipulation
@@ -7,10 +7,14 @@
 
 The following program demonstrates that in Ruby we accomplish most of the file I/O tasks without ever referring to GLib methods. Also you can see that error handling is a Ruby built in feature and rarely will you need any help prom GLib, perhaps only when investigating how to port low level "C" applications into Ruby or in the opposite direction. However there is an important distinction in how errors are handled when you do not use ((<GLib>)) file and directory manipulation methods.
 
+=== Error Handling
 :Important note about error handling
 
     When you use Ruby built in file and directory manipulation functionality, you should know that they raise ((*StandardError*)) exceptions rather than GLib::FileError exceptions which are used by ((<GLib>)). This is not obvious to a novice to Ruby GTK+, especially if one gets comfortable with Ruby GTK+ API documentation. This may not be relevant until, if ever, there will be Ruby equivalents of g_file_set_contents, and g_file_get_contents functions implemented. 
 
+    {{br}}
+    I see no reason for this two to be separated especially, because GLib::FileError is part of the ((*Exception*)) object hierarchy. However, currently (as of Ruby 1.8.6 and Ruby-GNOME2 rel.: 2-0.17.0-rc1) there seems to be a problem in this area, and we should expect this to be soon corrected. 
+
 Here is the example program:
 
  #!/usr/bin/env ruby
@@ -51,7 +55,11 @@
  end                                  # Automatically close.
 
 
-You must have noticed there are no GUI elements in the above program.  There should be! If it wern't for the GLib#home_dir we could do without the ((*require 'gtk2'.*))For instance in the error handling routine you should really implement the message dialogue to provide user with information and a possible recovery options, such as inserting a CD ROM, closing the device door, or connecting a read/write device. Also, note that in the above program the following error handling would not work:
+You must have noticed there are no GUI elements in the above program. There should be! If it wern't for the GLib#home_dir we could do without the ((*require 'gtk2'.*)) For instance in the error handling routine you should really implement the message dialogue to provide user with information and a possible recovery options, such as inserting a CD ROM, closing the device door, or connecting a read/write device. Also, note that in the above program currently the following error handling would not work:
 
  tries = 0
  begin  # Establish error handling block
@@ -71,5 +75,7 @@
  else
    puts "All went well."
  end  # End error handling block
-
-Ruby has a rich set of file and directory manipulation methods. You should check out the 9th chapter covering "(9.6) Files and Directories" and "(9.7) Input/Output" in  Ruby book by D. Flanagan and Y. Matsumoto "The Ruby Programming Language" - defacto Ruby manual (in my opinion  the best Ruby book up to date).




ruby-gnome2-cvs メーリングリストの案内
Back to archive index