Class: Unicode::Japanese
- Inherits:
-
Object
show all
- Defined in:
- lib/unicode/japanese.rb,
lib/unicode/japanese/table.rb,
lib/unicode/japanese/pattern.rb
Defined Under Namespace
Modules: Pattern, Table
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(string) ⇒ Japanese
Returns a new instance of Japanese.
18
19
20
|
# File 'lib/unicode/japanese.rb', line 18
def initialize(string)
@string = string.to_s.dup
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
47
48
49
|
# File 'lib/unicode/japanese.rb', line 47
def method_missing(*args)
self.class.__send__(args[0], @string)
end
|
Instance Attribute Details
#string ⇒ Object
Returns the value of attribute string.
2
3
4
|
# File 'lib/unicode/japanese.rb', line 2
def string
@string
end
|
Class Method Details
.convert(action, string) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/unicode/japanese.rb', line 5
def convert(action, string)
pattern = Pattern.__send__(action) rescue raise(NotImplementedError, "Undefined Pattern: #{action}")
table = Table .__send__(action) rescue raise(NotImplementedError, "Undefined Table: #{action}")
string.gsub!(pattern){table[$1]}
return string
end
|
Instance Method Details
#h2z ⇒ Object
34
35
36
37
38
39
|
# File 'lib/unicode/japanese.rb', line 34
def h2z
h2zKana
h2zNum
h2zAlpha
h2zSym
end
|
#h2zKana ⇒ Object
41
42
43
44
|
# File 'lib/unicode/japanese.rb', line 41
def h2zKana
h2zKanaD
h2zKanaK
end
|
#z2h ⇒ Object
22
23
24
25
26
27
|
# File 'lib/unicode/japanese.rb', line 22
def z2h
z2hKana
z2hNum
z2hAlpha
z2hSym
end
|
#z2hKana ⇒ Object
29
30
31
32
|
# File 'lib/unicode/japanese.rb', line 29
def z2hKana
z2hKanaD
z2hKanaK
end
|