Module: JapanETC::Util

Included in:
DatabaseProvider::BaseNEXCO, Road, Tollbooth, Tollbooth::Identifier
Defined in:
lib/japan_etc/util.rb

Class Method Summary collapse

Class Method Details

.convert_fullwidth_characters_to_halfwidth(string) ⇒ Object



13
14
15
16
17
# File 'lib/japan_etc/util.rb', line 13

def convert_fullwidth_characters_to_halfwidth(string)
  return nil unless string

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

.convert_to_integer(object) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/japan_etc/util.rb', line 25

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

.normalize(string) ⇒ Object



7
8
9
10
11
# File 'lib/japan_etc/util.rb', line 7

def normalize(string)
  return nil unless string

  convert_fullwidth_characters_to_halfwidth(string)
end

.remove_whitespaces(string) ⇒ Object



19
20
21
22
23
# File 'lib/japan_etc/util.rb', line 19

def remove_whitespaces(string)
  return nil unless string

  string.tr(' ', '')
end