Class: CsvRowModel::Validators::NumberValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/csv_row_model/validators/number_validator.rb

Overview

:nodoc:

Direct Known Subclasses

FloatFormatValidator, IntegerFormatValidator

Instance Method Summary collapse

Instance Method Details

#before_after_decimal(value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/csv_row_model/validators/number_validator.rb', line 4

def before_after_decimal(value)
  value ||= ""

  # if value == "0003434.1233000"
  #   before = "3434"; after = "1233"
  before, decimal, after = value.partition(".")
  before.sub!(/\A0+/, "")
  after.sub!(/0+\z/, "")
  [before, after]
end