Class: Yosina::Transliterators::Jisx0201AndAlike::Transliterator
- Inherits:
-
BaseTransliterator
- Object
- BaseTransliterator
- Yosina::Transliterators::Jisx0201AndAlike::Transliterator
- Defined in:
- lib/yosina/transliterators/jisx0201_and_alike.rb
Overview
Transliterator for JIS X 0201 and alike
Instance Attribute Summary collapse
-
#combine_voiced_sound_marks ⇒ Object
readonly
Returns the value of attribute combine_voiced_sound_marks.
-
#convert_gl ⇒ Object
readonly
Returns the value of attribute convert_gl.
-
#convert_gr ⇒ Object
readonly
Returns the value of attribute convert_gr.
-
#convert_hiraganas ⇒ Object
readonly
Returns the value of attribute convert_hiraganas.
-
#convert_unsafe_specials ⇒ Object
readonly
Returns the value of attribute convert_unsafe_specials.
-
#fullwidth_to_halfwidth ⇒ Object
readonly
Returns the value of attribute fullwidth_to_halfwidth.
-
#u005c_as_backslash ⇒ Object
readonly
Returns the value of attribute u005c_as_backslash.
-
#u005c_as_yen_sign ⇒ Object
readonly
Returns the value of attribute u005c_as_yen_sign.
-
#u007e_as_fullwidth_macron ⇒ Object
readonly
Returns the value of attribute u007e_as_fullwidth_macron.
-
#u007e_as_fullwidth_tilde ⇒ Object
readonly
Returns the value of attribute u007e_as_fullwidth_tilde.
-
#u007e_as_overline ⇒ Object
readonly
Returns the value of attribute u007e_as_overline.
-
#u007e_as_wave_dash ⇒ Object
readonly
Returns the value of attribute u007e_as_wave_dash.
-
#u00a5_as_yen_sign ⇒ Object
readonly
Returns the value of attribute u00a5_as_yen_sign.
Instance Method Summary collapse
-
#call(input_chars) ⇒ Enumerable<Char>
Transliterate characters.
-
#initialize(options = {}) ⇒ Transliterator
constructor
Initialize the transliterator with options.
Constructor Details
#initialize(options = {}) ⇒ Transliterator
Initialize the transliterator with options
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 210 def initialize( = {}) super() @fullwidth_to_halfwidth = .fetch(:fullwidth_to_halfwidth, true) @convert_gl = .fetch(:convert_gl, true) @convert_gr = .fetch(:convert_gr, true) @convert_hiraganas = .fetch(:convert_hiraganas, false) @combine_voiced_sound_marks = .fetch(:combine_voiced_sound_marks, true) # Set defaults based on direction if @fullwidth_to_halfwidth @convert_unsafe_specials = .fetch(:convert_unsafe_specials, true) @u005c_as_yen_sign = .fetch(:u005c_as_yen_sign) { !.key?(:u00a5_as_yen_sign) } @u005c_as_backslash = .fetch(:u005c_as_backslash, false) @u007e_as_fullwidth_tilde = .fetch(:u007e_as_fullwidth_tilde, true) @u007e_as_wave_dash = .fetch(:u007e_as_wave_dash, true) @u007e_as_overline = .fetch(:u007e_as_overline, false) @u007e_as_fullwidth_macron = .fetch(:u007e_as_fullwidth_macron, false) @u00a5_as_yen_sign = .fetch(:u00a5_as_yen_sign, false) else @convert_unsafe_specials = .fetch(:convert_unsafe_specials, false) @u005c_as_yen_sign = .fetch(:u005c_as_yen_sign) { !.key?(:u005c_as_backslash) } @u005c_as_backslash = .fetch(:u005c_as_backslash, false) @u007e_as_fullwidth_tilde = .fetch(:u007e_as_fullwidth_tilde) do !.key?(:u007e_as_wave_dash) && !.key?(:u007e_as_overline) && !.key?(:u007e_as_fullwidth_macron) end @u007e_as_wave_dash = .fetch(:u007e_as_wave_dash, false) @u007e_as_overline = .fetch(:u007e_as_overline, false) @u007e_as_fullwidth_macron = .fetch(:u007e_as_fullwidth_macron, false) @u00a5_as_yen_sign = .fetch(:u00a5_as_yen_sign, true) end build_mappings! end |
Instance Attribute Details
#combine_voiced_sound_marks ⇒ Object (readonly)
Returns the value of attribute combine_voiced_sound_marks.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def combine_voiced_sound_marks @combine_voiced_sound_marks end |
#convert_gl ⇒ Object (readonly)
Returns the value of attribute convert_gl.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def convert_gl @convert_gl end |
#convert_gr ⇒ Object (readonly)
Returns the value of attribute convert_gr.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def convert_gr @convert_gr end |
#convert_hiraganas ⇒ Object (readonly)
Returns the value of attribute convert_hiraganas.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def convert_hiraganas @convert_hiraganas end |
#convert_unsafe_specials ⇒ Object (readonly)
Returns the value of attribute convert_unsafe_specials.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def convert_unsafe_specials @convert_unsafe_specials end |
#fullwidth_to_halfwidth ⇒ Object (readonly)
Returns the value of attribute fullwidth_to_halfwidth.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def fullwidth_to_halfwidth @fullwidth_to_halfwidth end |
#u005c_as_backslash ⇒ Object (readonly)
Returns the value of attribute u005c_as_backslash.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u005c_as_backslash @u005c_as_backslash end |
#u005c_as_yen_sign ⇒ Object (readonly)
Returns the value of attribute u005c_as_yen_sign.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u005c_as_yen_sign @u005c_as_yen_sign end |
#u007e_as_fullwidth_macron ⇒ Object (readonly)
Returns the value of attribute u007e_as_fullwidth_macron.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u007e_as_fullwidth_macron @u007e_as_fullwidth_macron end |
#u007e_as_fullwidth_tilde ⇒ Object (readonly)
Returns the value of attribute u007e_as_fullwidth_tilde.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u007e_as_fullwidth_tilde @u007e_as_fullwidth_tilde end |
#u007e_as_overline ⇒ Object (readonly)
Returns the value of attribute u007e_as_overline.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u007e_as_overline @u007e_as_overline end |
#u007e_as_wave_dash ⇒ Object (readonly)
Returns the value of attribute u007e_as_wave_dash.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u007e_as_wave_dash @u007e_as_wave_dash end |
#u00a5_as_yen_sign ⇒ Object (readonly)
Returns the value of attribute u00a5_as_yen_sign.
187 188 189 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 187 def u00a5_as_yen_sign @u00a5_as_yen_sign end |
Instance Method Details
#call(input_chars) ⇒ Enumerable<Char>
Transliterate characters
251 252 253 254 255 256 257 |
# File 'lib/yosina/transliterators/jisx0201_and_alike.rb', line 251 def call(input_chars) if @fullwidth_to_halfwidth convert_fullwidth_to_halfwidth(input_chars) else convert_halfwidth_to_fullwidth(input_chars) end end |