class TidyFFI::Tidy
Clean and simple interface to Tidy
Constants
- OptionsContainer
Attributes
Public Class Methods
Source
# File lib/tidy_ffi/tidy.rb, line 29 def self.clean(str, options = {}) new(str, options).clean end
Returns cleaned string
Source
# 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
Source
# File lib/tidy_ffi/tidy.rb, line 66 def default_options=(options) default_options.merge_with_options(options) end
Default options for tidy. Works just like options= method
Source
# 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
Initializing object.
-
str is a string to tidy
-
options are options for tidy
Source
# File lib/tidy_ffi/tidy.rb, line 78 def validate_options? @validate_options != false end
When true it validates name and option type (default is true).
Source
# File lib/tidy_ffi/tidy.rb, line 73 def with_options(options) OptionsContainer::Proxy.new(self, @default_options, options) end
Returns a proxy class with options. Example:
TidyFFI::Tidy.with_options(:show_body_only => true).with_options(:wrap_asp => true).new('test)
Public Instance Methods
Source
# 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 cleaned string
Source
# File lib/tidy_ffi/tidy.rb, line 34 def errors @errors ||= begin clean @errors end end
Returns errors for string
Source
# File lib/tidy_ffi/tidy.rb, line 55 def options @options 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
Source
# File lib/tidy_ffi/tidy.rb, line 46 def options=(options) @options.merge_with_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.