module StrSanitizer::HtmlEntities
This modules encodes and decodes HTML Entities of a string
Author: Jakaria (mailto: jakariablaine120@gmail.com) Copyright: Copyright © 2017 Jakaria
Public Instance Methods
html_decode(string)
click to toggle source
Decodes the HTML entities of the given string
Params:
str
-
A
string
which needs to be decoded to html entities
Returns:
string
-
A string with decoded HTML entities
string
# File lib/str_sanitizer/html_entities.rb, line 41 def html_decode(string) @coder = HTMLEntities.new @coder.decode(string) end
html_encode(string, *options)
click to toggle source
Encodes the HTML entities of the given string
Params:
str
-
A
string
which needs to be escaped from html entities options
-
Options for encoding. You can provide one or more than one option. If no option is given, :basic option will be used by default. Options available :basic, :named, :decimal, :hexadecimal
Returns:
string
-
An HTML entities escaped
string
# File lib/str_sanitizer/html_entities.rb, line 29 def html_encode(string, *options) @coder = HTMLEntities.new @coder.encode(string, *options) end
initizalize()
click to toggle source
Instantiate htmlentities class to use it for encoding and decoding html entities
Params: none
# File lib/str_sanitizer/html_entities.rb, line 15 def initizalize @coder = HTMLEntities.new end