Module: FeCoreExt::CoreExt::String

Included in:
String
Defined in:
lib/fe_core_ext/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#kana_upcaseObject



39
40
41
# File 'lib/fe_core_ext/core_ext/string.rb', line 39

def kana_upcase
  tr('ァィゥェォヵヶッャュョヮ','アイウエオカケツヤユヨワ')
end

#match?(str) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fe_core_ext/core_ext/string.rb', line 35

def match?(str)
  /#{str}/ === self
end

#not_number?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/fe_core_ext/core_ext/string.rb', line 23

def not_number?
  to_i == 0 && match('0').nil?
end

#to_date_in_jaObject



53
54
55
# File 'lib/fe_core_ext/core_ext/string.rb', line 53

def to_date_in_ja
  match(/(\d{4})年(\d{1,2})月(\d{1,2})日/){ Date.new($1.to_i, $2.to_i, $3.to_i) }
end

#to_decimalObject



14
15
16
17
# File 'lib/fe_core_ext/core_ext/string.rb', line 14

def to_decimal
  return if not_number?
  delete(',').to_d
end

#to_han_kanaObject



43
44
45
46
# File 'lib/fe_core_ext/core_ext/string.rb', line 43

def to_han_kana
  return if self.nil?
  NKF.nkf('-wxZ4', self)
end

#to_integerObject



9
10
11
12
# File 'lib/fe_core_ext/core_ext/string.rb', line 9

def to_integer
  return if not_number?
  delete(',').to_i
end

#to_katakanaObject



31
32
33
# File 'lib/fe_core_ext/core_ext/string.rb', line 31

def to_katakana
  tr('ぁ-ん', 'ァ-ン')
end

#to_pathnameObject



19
20
21
# File 'lib/fe_core_ext/core_ext/string.rb', line 19

def to_pathname
  Pathname(self)
end

#to_zen_kanaObject



48
49
50
51
# File 'lib/fe_core_ext/core_ext/string.rb', line 48

def to_zen_kana
  return if self.nil?
  NKF.nkf('-wX',self)
end

#zen_to_hanObject



27
28
29
# File 'lib/fe_core_ext/core_ext/string.rb', line 27

def zen_to_han
  tr('0-9A-Za-z &・-()', '0-9A-Za-z &・\-()')
end