Class: Xmfun::Util::Decoder
- Inherits:
-
Object
- Object
- Xmfun::Util::Decoder
- Defined in:
- lib/xmfun/util/decoder.rb
Class Method Summary collapse
Class Method Details
.decode(input) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/xmfun/util/decoder.rb', line 9 def self.decode(input) row, text = strtok(input) tmp = text.in_groups(row).transpose.join CGI::unescape(tmp).gsub("^", "0") rescue ArgumentError false end |
.strtok(s) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/xmfun/util/decoder.rb', line 18 def self.strtok(s) m = /^(\d+)/.match(s) raise ArgumentError, "invalid input #{s}" unless m [$1.to_i, $'.chars.to_a] end |