Class: Spreewald::Steps::FollowTheLink
- Inherits:
-
Object
- Object
- Spreewald::Steps::FollowTheLink
- Defined in:
- lib/steps/follow_the_link.rb
Defined Under Namespace
Classes: NoVisitableLinkFound
Constant Summary collapse
- URL_PATTERN =
%r((?:https?://[^/]+)([^"'\s]+))
Instance Method Summary collapse
-
#initialize(mail, index_in_words) ⇒ FollowTheLink
constructor
A new instance of FollowTheLink.
- #run ⇒ Object
Constructor Details
#initialize(mail, index_in_words) ⇒ FollowTheLink
Returns a new instance of FollowTheLink.
20 21 22 23 |
# File 'lib/steps/follow_the_link.rb', line 20 def initialize(mail, index_in_words) @mail = mail @index_in_words = index_in_words end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/steps/follow_the_link.rb', line 25 def run index = { nil => 0, 'first' => 0, 'second' => 1, 'third' => 2 }[@index_in_words] paths = if @mail.html_part || body_text_html? search_for_links_in_html else search_for_links_in_plaintext end if paths[index] visit_path paths[index] else raise NoVisitableLinkFound.new(paths, @index_in_words) unless paths[index] end end |