e4u 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/e4u/kddi.rb +18 -2
- data/spec/kddi_spec.rb +8 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/e4u/kddi.rb
CHANGED
@@ -66,8 +66,24 @@ module E4U
|
|
66
66
|
end
|
67
67
|
|
68
68
|
class KDDIWeb::Emoji < KDDI::Emoji
|
69
|
-
|
70
|
-
|
69
|
+
alias :parent_initialize :initialize
|
70
|
+
alias :parent_unicode_to_cp932 :unicode_to_cp932
|
71
|
+
|
72
|
+
def initialize attributes
|
73
|
+
attributes = attributes.dup
|
74
|
+
attributes.each do |key, val|
|
75
|
+
next unless key == :unicode
|
76
|
+
hex = val.sub(/\A[\>\*\+]/, '')
|
77
|
+
break if hex.size == 0
|
78
|
+
attributes[key] = hex.split(/\+/, -1).map { |ch|
|
79
|
+
"%04X" % [parent_unicode_to_cp932(ch.hex) - 1792]
|
80
|
+
}.join('+')
|
81
|
+
end
|
82
|
+
parent_initialize attributes
|
83
|
+
end
|
84
|
+
|
85
|
+
def unicode_to_cp932 octet
|
86
|
+
octet + 1792
|
71
87
|
end
|
72
88
|
end
|
73
89
|
end
|
data/spec/kddi_spec.rb
CHANGED
@@ -47,6 +47,10 @@ describe E4U::KDDI do
|
|
47
47
|
@emj = @kddi.find{ |e| e[:number] == '44' }.kddi_emoji
|
48
48
|
end
|
49
49
|
|
50
|
+
it "unicodeが返ってくること" do
|
51
|
+
@emj.unicode.should == 'E488'
|
52
|
+
end
|
53
|
+
|
50
54
|
it "utf8が返ってくること" do
|
51
55
|
@emj.utf8.should == [0xE488].pack('U')
|
52
56
|
end
|
@@ -65,6 +69,10 @@ describe E4U::KDDI do
|
|
65
69
|
@emj = @kddi.find{ |e| e[:number] == '44' }.kddiweb_emoji
|
66
70
|
end
|
67
71
|
|
72
|
+
it "unicodeが変化していること" do
|
73
|
+
@emj.unicode.should == 'EF60'
|
74
|
+
end
|
75
|
+
|
68
76
|
it "utf8が返ってくること" do
|
69
77
|
@emj.utf8.should == [0xEF60].pack('U')
|
70
78
|
end
|