Class: EmailDoc::Document

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/email_doc/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, mail, ex) ⇒ Document

Returns a new instance of Document.



13
14
15
16
17
# File 'lib/email_doc/document.rb', line 13

def initialize(context, mail, ex)
  @context = context
  @mail    = mail
  @ex      = ex
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/email_doc/document.rb', line 8

def context
  @context
end

#exObject (readonly)

Returns the value of attribute ex.



8
9
10
# File 'lib/email_doc/document.rb', line 8

def ex
  @ex
end

#mailObject (readonly)

Returns the value of attribute mail.



8
9
10
# File 'lib/email_doc/document.rb', line 8

def mail
  @mail
end

Instance Method Details

#pathnameObject



38
39
40
41
42
43
44
# File 'lib/email_doc/document.rb', line 38

def pathname
  @pathname ||= begin
    dir  = './doc/mail/'
    path = ex.file_path.gsub(%r<\./spec/mailers/(.+)_spec\.rb>, '\1.md')
    Pathname.new(dir + path)
  end
end

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/email_doc/document.rb', line 19

def render
  ERB.new(<<-MD_END).result(binding)
# #{described_class}

## #{ex.description}

```
From: #{from}
 Subject: #{subject}
  To: #{to}
Reply to: #{reply_to}
```

```
#{body.encoded}
```
MD_END
end