Module: DynamicActiveResource::Helpers
- Defined in:
- lib/dynamic_active_resource/helpers.rb
Class Method Summary collapse
Class Method Details
.encode2html(string) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dynamic_active_resource/helpers.rb', line 16 def Helpers.encode2html(string) html_char_map = { '[' => '%5B', ']' => '%5D', '(' => '%28', ')' => '%29', ',' => '%2C', ' ' => '%20', '=' => '%3D', '\'' => '%27', '<' => '%3C', '>' => '%3E', } string.strip! if string encoded_string = '' string.each_char do |char| encoded_string << (html_char_map[char] || char) end encoded_string end |
.fast_token ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/dynamic_active_resource/helpers.rb', line 3 def Helpers.fast_token values = [ rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000), ] "%04x%04x%04x%04x%04x%06x%06x" % values end |