Class: Packr::Encoder
- Inherits:
-
Object
- Object
- Packr::Encoder
- Defined in:
- lib/packr/encoder.rb
Instance Method Summary collapse
- #encode(script) ⇒ Object
-
#initialize(pattern = nil, encoder = nil, ignore = nil) ⇒ Encoder
constructor
A new instance of Encoder.
- #search(script) ⇒ Object
Constructor Details
Instance Method Details
#encode(script) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/packr/encoder.rb', line 19 def encode(script) words = search(script) words.sort! index = 0 words.each do |word, key| word.encoded = @encoder.call(index) index += 1 end @parser.put_at(-1, lambda { |word, *args| words.get(word).encoded }) @parser.exec(script) end |