Class: GreenPepper::BoolType
- Defined in:
- lib/greenpepper/converter.rb
Class Method Summary collapse
Methods inherited from TypeBase
Class Method Details
.convert ⇒ Object
152 153 154 155 156 |
# File 'lib/greenpepper/converter.rb', line 152 def self.convert Proc.new{ |s| (/true|yes/i =~ s) != nil } end |
.format ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/greenpepper/converter.rb', line 158 def self.format Proc.new{ |b,expected_format| yes = "yes" no = "no" case expected_format when /^True|False$/ b.to_s.capitalize when /^yes|no$/ b ? yes : no when /^Yes|No$/ b ? yes.capitalize : no.capitalize else b.to_s end } end |
.regex ⇒ Object
148 149 150 |
# File 'lib/greenpepper/converter.rb', line 148 def self.regex /^\s*(true|false|yes|no)\s*$/i end |