Class: E4U::Base::Emoji
Instance Method Summary
collapse
Constructor Details
#initialize(attributes) ⇒ Emoji
Returns a new instance of Emoji.
54
55
56
57
58
59
60
|
# File 'lib/e4u/base.rb', line 54
def initialize attributes
attributes.each do |key, value|
next if key =~ /\A(id|object_id|__(id|send)__)\z/
instance_variable_set("@#{key}", value)
self.class.__send__ :attr_reader, key.to_sym
end
end
|
Instance Method Details
#alternate? ⇒ Boolean
62
63
64
|
# File 'lib/e4u/base.rb', line 62
def alternate?
!!(unicode =~ /\A>/)
end
|
#cp932 ⇒ Object
Also known as:
sjis
72
73
74
75
76
77
78
|
# File 'lib/e4u/base.rb', line 72
def cp932
hex = unicode.sub(/\A[\>\*\+]/, '')
raise if hex.size == 0
chr = hex.split(/\+/, -1).map{ |ch| unicode_to_cp932(ch.hex) }.pack('n*')
chr.force_encoding('CP932') if chr.respond_to? :force_encoding
chr
end
|
66
67
68
69
70
|
# File 'lib/e4u/base.rb', line 66
def utf8
hex = unicode.sub(/\A[\>\*\+]/, '')
raise if hex.size == 0
hex.split(/\+/, -1).map{ |ch| ch.hex }.pack('U*')
end
|