Class: HtmlSurgeon::Service
- Inherits:
-
Object
- Object
- HtmlSurgeon::Service
- Defined in:
- lib/html_surgeon/service.rb
Instance Attribute Summary collapse
-
#given_html ⇒ Object
readonly
Returns the value of attribute given_html.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #audit? ⇒ Boolean
- #css(css_selector) ⇒ Object
- #html ⇒ Object
-
#initialize(html_string, audit: false, **extra_options) ⇒ Service
constructor
A new instance of Service.
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, **) @given_html = html_string @audit = audit @options = .merge audit: audit end |
Instance Attribute Details
#given_html ⇒ Object (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 |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/html_surgeon/service.rb', line 3 def @options end |
Instance Method Details
#audit? ⇒ 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 |
#html ⇒ Object
11 12 13 |
# File 'lib/html_surgeon/service.rb', line 11 def html @html ||= doc.to_html end |