Class: HtmlSurgeon::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/html_surgeon/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(html_string, audit: false, **extra_options) ⇒ Service

Returns a new instance of Service.



5
6
7
8
9
# File 'lib/html_surgeon/service.rb', line 5

def initialize(html_string, audit: false, **extra_options)
  @given_html = html_string
  @audit      = audit
  @options    = extra_options.merge audit: audit
end

Instance Attribute Details

#given_htmlObject (readonly)

Returns the value of attribute given_html.



3
4
5
# File 'lib/html_surgeon/service.rb', line 3

def given_html
  @given_html
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/html_surgeon/service.rb', line 3

def options
  @options
end

Instance Method Details

#audit?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/html_surgeon/service.rb', line 15

def audit?
  !!@audit
end

#css(css_selector) ⇒ Object



19
20
21
22
# File 'lib/html_surgeon/service.rb', line 19

def css(css_selector)
  node_set = doc.css(css_selector)
  ChangeSet.new(node_set, self)
end

#htmlObject



11
12
13
# File 'lib/html_surgeon/service.rb', line 11

def html
  @html ||= doc.to_html
end