Class: Nydp::Html::PercentEncode

Inherits:
Object
  • Object
show all
Includes:
Builtin::Base, Singleton
Defined in:
lib/nydp/html.rb

Instance Method Summary collapse

Instance Method Details

#invoke_2(vm, arg) ⇒ Object



40
41
42
# File 'lib/nydp/html.rb', line 40

def invoke_2 vm, arg
  vm.push_arg Nydp::StringAtom.new percent_encode arg.to_s
end

#percent_encode(s) ⇒ Object



44
45
46
# File 'lib/nydp/html.rb', line 44

def percent_encode s
  s.gsub('%', '%25').gsub(/[ \n"\?.<>\\^_`{\|}~\[\]\/]/) { |x| "%%%2X" % x.ord }
end