Sha256: e067b3264215277dbe09300e2d66b1ab5dea299d3f0f9048582c61b123e76aa6

Contents?: true

Size: 435 Bytes

Versions: 5

Compression:

Stored size: 435 Bytes

Contents

# -*- encoding: utf-8 -*-

module TTY
  class Coercer

      class Integer

        def self.coerce(value, strict=true)
          begin
            Kernel.send(:Integer, value.to_s)
          rescue
            if strict
              raise InvalidArgument, "#{value} could not be coerced into Integer"
            else
              value.to_i
            end
          end
        end

      end # Integer

  end # Coercer
end # TTY

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tty-0.0.11 lib/tty/coercer/integer.rb
tty-0.0.10 lib/tty/coercer/integer.rb
tty-0.0.9 lib/tty/coercer/integer.rb
tty-0.0.8 lib/tty/coercer/integer.rb
tty-0.0.7 lib/tty/coercer/integer.rb