Module: KakasiParser

Defined in:
lib/kakasi_parser.rb,
lib/kakasi_parser/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.kakasi(options, original) ⇒ Object



9
10
11
# File 'lib/kakasi_parser.rb', line 9

def self.kakasi(options, original)
  parse(Kakasi.kakasi(options, original))
end

.parse(kakasi_result) ⇒ Object



5
6
7
# File 'lib/kakasi_parser.rb', line 5

def self.parse(kakasi_result)
  kakasi_result.scan(/[^{}]+/).map{ |match| match.split('|') }.reduce{ |a, b| a.product(b) }.map{ |reading| reading.is_a?(Array) ? reading.join : reading }
end