class KanjiMaster::Reader
Public Instance Methods
alphabet?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 3 def alphabet?(text) !(RegexConstant::NON_ENGLISH_REGEX === text) end
kanji?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 15 def kanji?(text) RegexConstant::KANJI_REGEX === text end
maybe_kanji?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 11 def maybe_kanji?(text) !alphabet?(text) end
number?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 7 def number?(text) (RegexConstant::NUMBER_REGEX === text) end
postal_code?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 20 def postal_code?(text); zipcode?(text) end
postcode?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 21 def postcode?(text); zipcode?(text) end
read_text(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 26 def read_text(text) matched_kanji = text.match(RegexConstant::KANJI_REGEX) text_analyse = {} text_analyse[:full_text] = text text_analyse[:alphabets] = text.tr('^A-Za-z', '') text_analyse[:numbers] = text.tr('^0-9', '') text_analyse[:kanjis] = matched_kanji[0] if matched_kanji Text.new(text_analyse) end
zip_code?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 19 def zip_code?(text); zipcode?(text) end
zipcode?(text)
click to toggle source
# File lib/kanji_master/reader.rb, line 22 def zipcode?(text) RegexConstant::JP_ZIPCODE_REGEX === text end