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

Returns a new instance of 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
# File 'lib/nokogiri_bang_finders.rb', line 25

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