Module: Truty::Conversion
- Included in:
- Truty
- Defined in:
- lib/truty/conversion.rb
Overview
Module with conversion engine for plain text. Converts to HTML.
Instance Method Summary collapse
-
#convert(input, conversion = :html, lang = :general) ⇒ String
Fixes the typography and also converts the string.
-
#html(input) ⇒ String
Escapes string to HTML entities.
-
#none(input) ⇒ String
Returns the input as it is.
Instance Method Details
#convert(input, conversion = :html, lang = :general) ⇒ String
Fixes the typography and also converts the string.
15 16 17 18 19 20 |
# File 'lib/truty/conversion.rb', line 15 def convert(input, conversion = :html, lang = :general) if !Truty.respond_to? conversion then conversion = :none end Truty.send(conversion, Truty.fix(input, lang)) end |
#html(input) ⇒ String
Escapes string to HTML entities.
26 27 28 29 |
# File 'lib/truty/conversion.rb', line 26 def html(input) coder = HTMLEntities.new coder.encode(input, :named, :decimal) end |
#none(input) ⇒ String
Returns the input as it is.
35 36 37 |
# File 'lib/truty/conversion.rb', line 35 def none(input) input end |