Class TidyFFI::Tidy
In: lib/tidy_ffi/tidy.rb
lib/tidy_ffi/tidy.rb
Parent: Object

Clean and simple interface to Tidy

Methods

Classes and Modules

Class TidyFFI::Tidy::InvalidOptionName
Class TidyFFI::Tidy::InvalidOptionValue

Constants

OptionsContainer = TidyFFI::OptionsContainer
OptionsContainer = TidyFFI::OptionsContainer

Attributes

validate_options  [W] 
validate_options  [W] 

Public Class methods

Returns cleaned string

[Source]

    # File lib/tidy_ffi/tidy.rb, line 29
29:   def self.clean(str, options = {})
30:     new(str, options).clean
31:   end

Returns cleaned string

[Source]

    # File lib/tidy_ffi/tidy.rb, line 29
29:   def self.clean(str, options = {})
30:     new(str, options).clean
31:   end

Default options for tidy. Works just like options method

[Source]

    # File lib/tidy_ffi/tidy.rb, line 61
61:     def default_options
62:       @default_options ||= OptionsContainer.new
63:     end

Default options for tidy. Works just like options method

[Source]

    # File lib/tidy_ffi/tidy.rb, line 61
61:     def default_options
62:       @default_options ||= OptionsContainer.new
63:     end

Default options for tidy. Works just like options= method

[Source]

    # File lib/tidy_ffi/tidy.rb, line 66
66:     def default_options=(options)
67:       @default_options.merge_with_options(options)
68:     end

Default options for tidy. Works just like options= method

[Source]

    # File lib/tidy_ffi/tidy.rb, line 66
66:     def default_options=(options)
67:       @default_options.merge_with_options(options)
68:     end

Initializing object.

[Source]

    # File lib/tidy_ffi/tidy.rb, line 11
11:   def initialize(str, options = {})
12:     @string = str
13:     @options = OptionsContainer.new(self.class.default_options)
14:     self.options = options
15:   end

Initializing object.

[Source]

    # File lib/tidy_ffi/tidy.rb, line 11
11:   def initialize(str, options = {})
12:     @string = str
13:     @options = OptionsContainer.new(self.class.default_options)
14:     self.options = options
15:   end

When true it validates name and option type (default is true).

[Source]

    # File lib/tidy_ffi/tidy.rb, line 78
78:     def validate_options?
79:       @validate_options != false
80:     end

When true it validates name and option type (default is true).

[Source]

    # File lib/tidy_ffi/tidy.rb, line 78
78:     def validate_options?
79:       @validate_options != false
80:     end

Returns a proxy class with options. Example:

  TidyFFI::Tidy.with_options(:show_body_only => true).with_options(:wrap_asp => true).new('test)

[Source]

    # File lib/tidy_ffi/tidy.rb, line 73
73:     def with_options(options)
74:       OptionsContainer::Proxy.new(self, @default_options, options)
75:     end

Returns a proxy class with options. Example:

  TidyFFI::Tidy.with_options(:show_body_only => true).with_options(:wrap_asp => true).new('test)

[Source]

    # File lib/tidy_ffi/tidy.rb, line 73
73:     def with_options(options)
74:       OptionsContainer::Proxy.new(self, @default_options, options)
75:     end

Public Instance methods

Returns cleaned string

[Source]

    # File lib/tidy_ffi/tidy.rb, line 18
18:   def clean
19:     @clean ||= TidyFFI::Interface.with_doc do |doc|
20:       doc.apply_options(@options.to_hash!)
21:       doc.string = @string
22:       doc.clean
23:       @errors = doc.errors
24:       doc.output
25:     end
26:   end

Returns cleaned string

[Source]

    # File lib/tidy_ffi/tidy.rb, line 18
18:   def clean
19:     @clean ||= TidyFFI::Interface.with_doc do |doc|
20:       doc.apply_options(@options.to_hash!)
21:       doc.string = @string
22:       doc.clean
23:       @errors = doc.errors
24:       doc.output
25:     end
26:   end

Returns errors for string

[Source]

    # File lib/tidy_ffi/tidy.rb, line 34
34:   def errors
35:     @errors ||= begin
36:       clean
37:       @errors
38:     end
39:   end

Returns errors for string

[Source]

    # File lib/tidy_ffi/tidy.rb, line 34
34:   def errors
35:     @errors ||= begin
36:       clean
37:       @errors
38:     end
39:   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 55
55:   def options
56:     @options
57:   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 55
55:   def options
56:     @options
57:   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.

[Source]

    # File lib/tidy_ffi/tidy.rb, line 46
46:   def options=(options)
47:     @options.merge_with_options(options)
48:   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.

[Source]

    # File lib/tidy_ffi/tidy.rb, line 46
46:   def options=(options)
47:     @options.merge_with_options(options)
48:   end

[Validate]