Class: ExpressMailer::Attributes

Inherits:
Object
  • Object
show all
Defined in:
lib/express_mailer/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Attributes

Returns a new instance of Attributes.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/express_mailer/attributes.rb', line 14

def initialize(options = {})
  @configuration = ExpressMailer.configuration
  @style = options.fetch(:style, :info)
  @to = options.fetch(:to, @configuration.default_to)
  @from = options.fetch(:from, @configuration.default_from)
  @reply_to = options.fetch(:reply_to, nil)
  @subject = options.fetch(:subject, "Express Mail")
  @preheader = options.fetch(:preheader, Date.today.strftime('%B %-d, %Y'))
  @header = options.fetch(:header, @subject)
  @footer = options.fetch(:footer, @configuration.default_footer)
  @headline = options.fetch(:headline, nil)
  @image = ExpressMailer::Image.create(options.fetch(:image, nil))
  @table = ExpressMailer::Table.create(options.fetch(:table, nil))
  @button = ExpressMailer::Button.create(options.fetch(:button, nil))
  @text = options.fetch(:text, nil)
end

Instance Attribute Details

#button ⇒ Object

Returns the value of attribute button.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def button
  @button
end

#configuration ⇒ Object

Returns the value of attribute configuration.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def configuration
  @configuration
end

Returns the value of attribute footer.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def footer
  @footer
end

#from ⇒ Object

Returns the value of attribute from.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def from
  @from
end

#header ⇒ Object

Returns the value of attribute header.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def header
  @header
end

#headline ⇒ Object

Returns the value of attribute headline.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def headline
  @headline
end

#image ⇒ Object

Returns the value of attribute image.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def image
  @image
end

#preheader ⇒ Object

Returns the value of attribute preheader.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def preheader
  @preheader
end

#reply_to ⇒ Object

Returns the value of attribute reply_to.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def reply_to
  @reply_to
end

#style ⇒ Object

Returns the value of attribute style.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def style
  @style
end

#subject ⇒ Object

Returns the value of attribute subject.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def subject
  @subject
end

#table ⇒ Object

Returns the value of attribute table.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def table
  @table
end

#text ⇒ Object

Returns the value of attribute text.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def text
  @text
end

#to ⇒ Object

Returns the value of attribute to.



7
8
9
# File 'lib/express_mailer/attributes.rb', line 7

def to
  @to
end

Instance Method Details

#button_background_color ⇒ Object



43
44
45
# File 'lib/express_mailer/attributes.rb', line 43

def button_background_color
  @configuration.instance_variable_get(:"@#{@style}_button_background_color")
end

#button_text_color ⇒ Object



39
40
41
# File 'lib/express_mailer/attributes.rb', line 39

def button_text_color
  @configuration.instance_variable_get(:"@#{@style}_button_text_color")
end

#headline_text_color ⇒ Object



35
36
37
# File 'lib/express_mailer/attributes.rb', line 35

def headline_text_color
  @configuration.instance_variable_get(:"@#{@style}_text_color")
end

#text_align ⇒ Object



47
48
49
50
51
52
53
# File 'lib/express_mailer/attributes.rb', line 47

def text_align
  if @text.to_s.length > 240
    :left
  else
    :center
  end
end

#text_size ⇒ Object



55
56
57
58
59
60
61
# File 'lib/express_mailer/attributes.rb', line 55

def text_size
  if @text.to_s.length > 60
    20
  else
    26
  end
end