Class: EmailHelper::EmailBody

Inherits:
Object
  • Object
show all
Defined in:
lib/watirmark/cucumber/email_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ EmailBody

Returns a new instance of EmailBody.



104
105
106
107
# File 'lib/watirmark/cucumber/email_helper.rb', line 104

def initialize(body)
  @body = body
  @doc = ::Nokogiri::HTML.parse body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



102
103
104
# File 'lib/watirmark/cucumber/email_helper.rb', line 102

def body
  @body
end

#docObject

Returns the value of attribute doc.



102
103
104
# File 'lib/watirmark/cucumber/email_helper.rb', line 102

def doc
  @doc
end

Instance Method Details

#inspectObject



131
132
133
# File 'lib/watirmark/cucumber/email_helper.rb', line 131

def inspect
  @doc.to_s
end


119
120
121
122
123
124
125
126
127
128
129
# File 'lib/watirmark/cucumber/email_helper.rb', line 119

def link(how, matcher)
  links.each do |link|
    case how
      when :text
        return link if /#{matcher}/.matches link.text
      when :href
        return link if /#{matcher}/.matches link.href
    end
  end
  nil
end


109
110
111
112
113
114
115
116
117
# File 'lib/watirmark/cucumber/email_helper.rb', line 109

def links
  unless @links
    @links = []
    @doc.xpath('//a').each do |link|
      @links << EmailLink.new(link)
    end
  end
  @links
end