Exception: Nokogiri::XML::NotFound

Inherits:
StandardError
  • Object
show all
Defined in:
lib/nokogiri_bang_finders.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(needle, haystack) ⇒ NotFound



22
23
24
# File 'lib/nokogiri_bang_finders.rb', line 22

def initialize(needle, haystack)
  @message = "#{needle} in \n#{snippet(haystack)}"
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



21
22
23
# File 'lib/nokogiri_bang_finders.rb', line 21

def message
  @message
end

Instance Method Details

#snippet(haystack) ⇒ Object



25
26
27
28
# File 'lib/nokogiri_bang_finders.rb', line 25

def snippet(haystack)
  snippet = haystack.to_s
  snippet.length > 200 ? "#{snippet[0...200]}..." : snippet
end