Sha256: 7a82929c4afab0f63579ed07b39e41d10975445453bb453089980221f0c8a2fe

Contents?: true

Size: 414 Bytes

Versions: 1

Compression:

Stored size: 414 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8

class String
  # http://taro-tnk.hatenablog.com/entry/2012/12/17/001552

  # Return true if the 'str' express integer, else return false.
  def self.integer?(str)
    begin
      Integer(str)
      true
    rescue ArgumentError
      false
    end
  end

  # Return true if the 'str' express integer, else return false.
  def integer?
    self.class.integer?(self)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
builtinextension-0.1.4 lib/string/integer.rb