Class: TemplateMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/metro/template_message.rb

Defined Under Namespace

Classes: Message

Instance Method Summary collapse

Constructor Details

#initialize(details = {}) ⇒ TemplateMessage

Returns a new instance of TemplateMessage.



3
4
5
6
7
8
# File 'lib/metro/template_message.rb', line 3

def initialize(details = {})
  @messages = Array(details[:message]) + Array(details[:messages])
  @details = details[:details]
  @website = details[:website]
  @email = details[:contact]
end

Instance Method Details

#emailObject



44
45
46
# File 'lib/metro/template_message.rb', line 44

def email
  Array(@email).map {|email| "* #{email}" }.join("\n")
end

#message_filenameObject



48
49
50
# File 'lib/metro/template_message.rb', line 48

def message_filename
  File.join(File.dirname(__FILE__),"..","templates","message.erb")
end

#message_templateObject



52
53
54
# File 'lib/metro/template_message.rb', line 52

def message_template
  File.read(message_filename)
end

#messagesObject



36
37
38
# File 'lib/metro/template_message.rb', line 36

def messages
  @messages.map {|m| Message.new m, @details }
end

#to_sObject



56
57
58
# File 'lib/metro/template_message.rb', line 56

def to_s
  ERB.new(message_template).result(binding)
end

#websiteObject



40
41
42
# File 'lib/metro/template_message.rb', line 40

def website
  Array(@website).map {|website| "* #{website}" }.join("\n")
end