Class: GreenPepper::FloatType

Inherits:
TypeBase
  • Object
show all
Defined in:
lib/greenpepper/converter.rb

Class Method Summary collapse

Methods inherited from TypeBase

can_parse?, inherited

Class Method Details

.convertObject



132
133
134
# File 'lib/greenpepper/converter.rb', line 132

def self.convert
  Proc.new{|s| s.to_f}
end

.formatObject



136
137
138
139
140
141
142
143
144
# File 'lib/greenpepper/converter.rb', line 136

def self.format
  Proc.new{ |b, expected_format|
    if expected_format.match /^.[0-9]+$/
      b.to_s[1..-1]
    else
      b.to_s
    end
  }
end

.regexObject



128
129
130
# File 'lib/greenpepper/converter.rb', line 128

def self.regex
  /^\s*-?[0-9]*\.[0-9]+\s*$/
end