Class: HtmlGen
- Inherits:
-
Object
- Object
- HtmlGen
- Defined in:
- lib/html_gen.rb
Overview
This class doesnt hold other methods than for autoloading of subclasses.
Defined Under Namespace
Classes: Element, Parser, TextEle
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
Autoloader for subclasses.
-
.escape_html(string) ⇒ Object
Escapes HTML from the given string.
Class Method Details
.const_missing(name) ⇒ Object
Autoloader for subclasses.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/html_gen.rb', line 6 def self.const_missing(name) file_path = "#{File.dirname(__FILE__)}/html_gen/#{::StringCases.camel_to_snake(name)}.rb" if File.exist?(file_path) require file_path return HtmlGen.const_get(name) if HtmlGen.const_defined?(name) end super end |
.escape_html(string) ⇒ Object
Escapes HTML from the given string. This is to avoid any dependencies and should not be used by other libs.
18 19 20 |
# File 'lib/html_gen.rb', line 18 def self.escape_html(string) string.to_s.gsub(/&/, "&").gsub(/\"/, """).gsub(/>/, ">").gsub(/</, "<") end |