2009-01-01ãã1ã¶æéã®è¨äºä¸è¦§
Ruby ã®ã¡ã½ããã®å¼æ°ãæ»ãå¤ã«ã¯åæå®ããªããã©ããããæå®ã§ãããããªä»çµã¿ãã¤ãã£ã¦ã¿ã¾ããã module Strict def strict(name, &block) @returns = Object @arguments = [] block.call m = instance_method(name) ret_type, arg_type = @returnsâ¦
ååã®ç¶ãã ããã©ã«ãå¤ :default ã§ãªãã·ã§ã³ãæå®ããªãæã®ããã©ã«ãå¤ãæå®ã§ãã¾ãã o = OptConfig.new o.option "port", :format=>1..65535, :default=>25 o.parse ["--port=123"] o["port"] # => 123 o.parse [] o["port"] # => 25 ã¢ã³ãã¼â¦
OptConfig ã¯é«æ©è½ãªãªãã·ã§ã³ãã¼ãµã§ããUNIX ã®ã³ãã³ãã©ã¤ã³å¼æ°ã§ä¸ãããããªãã·ã§ã³ããã¼ã¹ããããè¨å®ãã¡ã¤ã«ãããã©ã¡ã¼ã¿ãåå¾ã§ãã¾ãã使ç¨ä¾: o = OptConfig.new o.option "p", "port", :format=>1..65535, :default=>12345, :descripâ¦
StringValidator ã¯æååã®æ£å½æ§ãè©ä¾¡ããã©ã¤ãã©ãªã§ãã次ã®ããã«ä½¿ç¨ãã¾ãã StringValidator.validate è¦å, æåå è¦åã¯è²ããªå½¢å¼ã§è¨è¿°ã§ãã¾ãããã¨ãã°ãstr ãæ´æ°å¤ã§ãããã¨ãæå¾ ããå ´åã¯ã StringValidator.validate Integer, strâ¦
ã¯ã¦ãªãã¤ã¢ãªã¼ãã¡ããã¨ä½¿ã£ã¦ã¿ãããã¨ãã¨ããããæè¡ãã¿ã¯ãã£ã¡ã«æ¸ãã¦ã¿ããã¨ã«ã