Develop and Download Open Source Software

Browse Subversion Repository

Contents of /config/standard_validators.rb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24 - (show annotations) (download)
Tue Apr 10 13:07:50 2007 UTC (16 years, 11 months ago) by bluedwarf
File size: 1427 byte(s)
Improved the redraw method of Gtk.

1 # standard_validators.rb: an assembly of pre-defined validators for
2 # Edmaru::Config::ConfigElement.
3 #
4 # Copyright (C) 2007 Takashi Nakamoto
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 # 02110-1301 USA.
19 #
20
21 module Edmaru::Config
22 module Validators
23
24 #This validator accept an arbitrary string.
25 STRING_VALIDATOR = Proc.new{ |value|
26 raise "Not an instance of String was passed." if value.class != String
27 }
28
29 #This validator accept objects included in the specified array.
30 #To get a validator that accepts any one of "apple", "banana" or "orange",
31 #call this method like the following:
32 #
33 # LIST_VALIDATOR(["apple", "banana", "orange"])
34 def Validators.LIST_VALIDATOR(array)
35 Proc.new{ |value|
36 if !array.include?(value)
37 raise "#{value} is invalid."
38 end
39 }
40 end
41 end
42 end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26