Class: NHKore::Polisher

Inherits:
Object
  • Object
show all
Defined in:
lib/nhkore/polisher.rb

Overview

Author:

  • Jonathan Bradley Whited

Since:

  • 0.2.0

Direct Known Subclasses

BasicPolisher

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.polish_any(obj, polishers) ⇒ Object

Since:

  • 0.2.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/nhkore/polisher.rb', line 32

def self.polish_any(obj,polishers)
  return nil if obj.nil?

  polishers = Array(polishers)

  return obj if polishers.empty?

  if obj.is_a?(Word)
    obj = Word.new(
      kana: polish_any(obj.kana,polishers),
      kanji: polish_any(obj.kanji,polishers),
      word: obj
    )
  else # String
    polishers.each do |polisher|
      obj = polisher.polish(obj)
    end
  end

  return obj
end

Instance Method Details

#begin_polish(str) ⇒ Object

Since:

  • 0.2.0



21
22
23
# File 'lib/nhkore/polisher.rb', line 21

def begin_polish(str)
  return str
end

#polish(str) ⇒ Object

Since:

  • 0.2.0



25
26
27
28
29
30
# File 'lib/nhkore/polisher.rb', line 25

def polish(str)
  str = begin_polish(str)
  str = end_polish(str)

  return str
end