Class: TidyMachine
- Inherits:
-
Object
- Object
- TidyMachine
- Defined in:
- lib/tidy-machine.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :"tidy_mark" => false, :doctype => "omit" }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text) ⇒ TidyMachine
constructor
A new instance of TidyMachine.
- #tidy ⇒ Object
Constructor Details
#initialize(text) ⇒ TidyMachine
Returns a new instance of TidyMachine.
6 7 8 9 10 11 |
# File 'lib/tidy-machine.rb', line 6 def initialize(text) @text = text # TODO: check doctype html5 # # "<!DOCTYPE html>\n<html>\n<head>\n<title></title>\n</head>\n<body>\na string\n</body>\n</html>\n" end |
Class Method Details
.tidy(text) ⇒ Object
17 18 19 |
# File 'lib/tidy-machine.rb', line 17 def self.tidy(text) new(text).tidy end |
Instance Method Details
#tidy ⇒ Object
13 14 15 |
# File 'lib/tidy-machine.rb', line 13 def tidy TidyFFI::Tidy.(:"tidy_mark" => false, indent: "yes", doctype: "omit").new(@text).clean end |