Class: WordPart
- Inherits:
-
Object
- Object
- WordPart
- Defined in:
- lib/word_part.rb
Constant Summary collapse
- DT_RULES =
arrays: [output, predecessor-rule, successor-rule]
DetranslitRules.rules
- T_RULES =
TranslitRules.rules
Instance Attribute Summary collapse
-
#input ⇒ Object
may be more restricted than this.
-
#just_thru ⇒ Object
may be more restricted than this.
-
#prev ⇒ Object
may be more restricted than this.
-
#static_output ⇒ Object
may be more restricted than this.
-
#succ ⇒ Object
may be more restricted than this.
Class Method Summary collapse
Instance Method Summary collapse
-
#cyrillic_options(include_softeners) ⇒ Object
return array of (cyrillic) strings which can be empty (or nil instead?) –should we cache the result? i think it’s called no more than once.
-
#initialize(input, prev, detranslit = true) ⇒ WordPart
constructor
A new instance of WordPart.
Constructor Details
#initialize(input, prev, detranslit = true) ⇒ WordPart
Returns a new instance of WordPart.
16 17 18 19 20 |
# File 'lib/word_part.rb', line 16 def initialize input, prev, detranslit=true @input = input @prev = prev @is_detranslit = detranslit end |
Instance Attribute Details
#input ⇒ Object
may be more restricted than this
6 7 8 |
# File 'lib/word_part.rb', line 6 def input @input end |
#just_thru ⇒ Object
may be more restricted than this
6 7 8 |
# File 'lib/word_part.rb', line 6 def just_thru @just_thru end |
#prev ⇒ Object
may be more restricted than this
6 7 8 |
# File 'lib/word_part.rb', line 6 def prev @prev end |
#static_output ⇒ Object
may be more restricted than this
6 7 8 |
# File 'lib/word_part.rb', line 6 def static_output @static_output end |
#succ ⇒ Object
may be more restricted than this
6 7 8 |
# File 'lib/word_part.rb', line 6 def succ @succ end |
Class Method Details
Instance Method Details
#cyrillic_options(include_softeners) ⇒ Object
return array of (cyrillic) strings which can be empty (or nil instead?) –should we cache the result? i think it’s called no more than once.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/word_part.rb', line 31 def (include_softeners) return [input] if just_thru #this can be set to accomodate for untranslatable characters. ret = [] arr = @is_detranslit ? DT_RULES[input] : T_RULES[input] if arr #there are rules for this part, now see if any of them match arr.each do |rule| if match?(rule, include_softeners) ret << rule[0] end end end ret end |