Sha256: 61aa49c7a258ba511f92fd345237f75e0d4ac4df9ffadb8818513efaa2a61e40

Contents?: true

Size: 589 Bytes

Versions: 8

Compression:

Stored size: 589 Bytes

Contents

# frozen_string_literal: true

module JapanETC
  module Util
    module_function

    def normalize(string)
      return nil unless string

      convert_fullwidth_characters_to_halfwidth(string).strip
    end

    def convert_fullwidth_characters_to_halfwidth(string)
      return nil unless string

      string.tr(' A-Za-z0-9', ' A-Za-z0-9')
    end

    def convert_to_integer(object)
      case object
      when Numeric
        Integer(object)
      when String
        Integer(object.sub(/\A0+/, ''))
      else
        raise ArgumentError
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
japan_etc-0.6.0 lib/japan_etc/util.rb
japan_etc-0.5.2 lib/japan_etc/util.rb
japan_etc-0.5.1 lib/japan_etc/util.rb
japan_etc-0.5.0 lib/japan_etc/util.rb
japan_etc-0.4.0 lib/japan_etc/util.rb
japan_etc-0.3.0 lib/japan_etc/util.rb
japan_etc-0.2.0 lib/japan_etc/util.rb
japan_etc-0.1.0 lib/japan_etc/util.rb