Clean and simple interface to Tidy
Returns cleaned string
# File lib/tidy_ffi/tidy.rb, line 29 def self.clean(str, options = {}) new(str, options).clean end
Default options for tidy. Works just like options method
# File lib/tidy_ffi/tidy.rb, line 61 def default_options @default_options ||= OptionsContainer.new end
Default options for tidy. Works just like options= method
# File lib/tidy_ffi/tidy.rb, line 66 def default_options=(options) @default_options.merge_with_options(options) end
Initializing object.
str is a string to tidy
options are options for tidy
# File lib/tidy_ffi/tidy.rb, line 11 def initialize(str, options = {}) @string = str @options = OptionsContainer.new(self.class.default_options) self.options = options end
When true it validates name and option type (default is true).
# File lib/tidy_ffi/tidy.rb, line 78 def validate_options? @validate_options != false end
Returns a proxy class with options. Example:
TidyFFI::Tidy.with_options(:show_body_only => true).with_options(:wrap_asp => true).new('test)
# File lib/tidy_ffi/tidy.rb, line 73 def with_options(options) OptionsContainer::Proxy.new(self, @default_options, options) end
Returns cleaned string
# File lib/tidy_ffi/tidy.rb, line 18 def clean @clean ||= TidyFFI::Interface.with_doc do |doc| doc.apply_options(@options.to_hash!) doc.string = @string doc.clean @errors = doc.errors doc.output end end
Returns errors for string
# File lib/tidy_ffi/tidy.rb, line 34 def errors @errors ||= begin clean @errors end end
Proxy for options. Supports set and get
tidy.options.show_body_only #=> nil tidy.options.show_body_only = true tidy.options.show_body_only #=> true
# File lib/tidy_ffi/tidy.rb, line 55 def options @options end
Assigns options for tidy. It merges options, not deletes old ones.
tidy.options= {:wrap_asp => true} tidy.options= {:show_body_only => true}
Will send to tidy both options.
# File lib/tidy_ffi/tidy.rb, line 46 def options=(options) @options.merge_with_options(options) end