Sha256: d859a75cf444d18d2103462acaf07adf3912b0ce77d20e2c5d1b00eeccc7e8b3

Contents?: true

Size: 684 Bytes

Versions: 8

Compression:

Stored size: 684 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)
    end

    def convert_fullwidth_characters_to_halfwidth(string)
      return nil unless string

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

    def remove_whitespaces(string)
      return nil unless string

      string.tr(' ', '')
    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.14.0 lib/japan_etc/util.rb
japan_etc-0.13.0 lib/japan_etc/util.rb
japan_etc-0.12.0 lib/japan_etc/util.rb
japan_etc-0.11.0 lib/japan_etc/util.rb
japan_etc-0.10.0 lib/japan_etc/util.rb
japan_etc-0.9.0 lib/japan_etc/util.rb
japan_etc-0.8.0 lib/japan_etc/util.rb
japan_etc-0.7.0 lib/japan_etc/util.rb