Sha256: d79942e2cd1ff266155fae466e9af29eac7ceae52788dfe415a75185d2367f6c
Contents?: true
Size: 507 Bytes
Versions: 5
Compression:
Stored size: 507 Bytes
Contents
# frozen_string_literal: true module InferModel class Parsers::Integer extend Callable extend Dry::Initializer param :value option :allow_blank, default: -> { true } option :base, default: -> { 10 } def call raise Parsers::Error, "value was blank which is not allowed" if value.nil? && !allow_blank return if value.nil? || value.empty? Integer(value, base) rescue ArgumentError raise Parsers::Error, "'#{value}' is not an Integer" end end end
Version data entries
5 entries across 5 versions & 1 rubygems