Module: RCNB::Str
- Defined in:
- lib/rcnb/str.rb
Overview
Note:
使用using RCNB::Str来细化String类
字符串增强
Example
require 'rcnb/str'
using RCNB::Str
'Who NB?'.rcnb
# => ȐȼŃƅȓčƞÞƦȻƝƃŖć
'ȐĉņþƦȻƝƃŔć'.rcnb_decode
# => RCNB!
'ȐĉņþƦȻƝƃŔć'.rcnb?
# => RCNB!
'not rcnb'.rcnb?
# => nil
Instance Method Summary collapse
-
#rcnb(encoding = nil) ⇒ String
将字符串编码为RCNB密文.
-
#rcnb?(encoding = nil) ⇒ String?
判断字符串是否为RCNB密文.
-
#rcnb_decode(encoding = nil) ⇒ String
将RCNB密文字符串解码.
Instance Method Details
#rcnb(encoding = nil) ⇒ String
将字符串编码为RCNB密文
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rcnb/str.rb', line 41 refine String do # 将字符串编码为RCNB密文 # @param encoding 文本编码 def rcnb(encoding=nil) RCNB.encode(self,encoding) end # 将RCNB密文字符串解码 # @param encoding 文本编码 def rcnb_decode(encoding=nil) RCNB.decode(self,encoding) end # 判断字符串是否为RCNB密文 # @param encoding 文本编码 # @return [String,nil] 若是RCNB密文,则返回解码结果,否则返回nil def rcnb?(encoding=nil) begin RCNB.decode(self,encoding) rescue ArgumentError nil end end end |
#rcnb?(encoding = nil) ⇒ String?
判断字符串是否为RCNB密文
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rcnb/str.rb', line 41 refine String do # 将字符串编码为RCNB密文 # @param encoding 文本编码 def rcnb(encoding=nil) RCNB.encode(self,encoding) end # 将RCNB密文字符串解码 # @param encoding 文本编码 def rcnb_decode(encoding=nil) RCNB.decode(self,encoding) end # 判断字符串是否为RCNB密文 # @param encoding 文本编码 # @return [String,nil] 若是RCNB密文,则返回解码结果,否则返回nil def rcnb?(encoding=nil) begin RCNB.decode(self,encoding) rescue ArgumentError nil end end end |
#rcnb_decode(encoding = nil) ⇒ String
将RCNB密文字符串解码
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rcnb/str.rb', line 41 refine String do # 将字符串编码为RCNB密文 # @param encoding 文本编码 def rcnb(encoding=nil) RCNB.encode(self,encoding) end # 将RCNB密文字符串解码 # @param encoding 文本编码 def rcnb_decode(encoding=nil) RCNB.decode(self,encoding) end # 判断字符串是否为RCNB密文 # @param encoding 文本编码 # @return [String,nil] 若是RCNB密文,则返回解码结果,否则返回nil def rcnb?(encoding=nil) begin RCNB.decode(self,encoding) rescue ArgumentError nil end end end |