Class: ExpressMailer::Image

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Image

Returns a new instance of Image.



13
14
15
16
17
18
19
# File 'lib/express_mailer/image.rb', line 13

def initialize(options = {})
  @url = options.fetch(:url)
  @alt = options.fetch(:alt)
  @background = options.fetch(:background, 'transparent')
  @shape = options.fetch(:shape, :normal) # :normal, :circle, :rounded
  @size = options.fetch(:size, :normal) # :normal, :large
end

Instance Attribute Details

#alt ⇒ Object

Returns the value of attribute alt.



3
4
5
# File 'lib/express_mailer/image.rb', line 3

def alt
  @alt
end

#background ⇒ Object

Returns the value of attribute background.



3
4
5
# File 'lib/express_mailer/image.rb', line 3

def background
  @background
end

#shape ⇒ Object

Returns the value of attribute shape.



3
4
5
# File 'lib/express_mailer/image.rb', line 3

def shape
  @shape
end

#size ⇒ Object

Returns the value of attribute size.



3
4
5
# File 'lib/express_mailer/image.rb', line 3

def size
  @size
end

#url ⇒ Object

Returns the value of attribute url.



3
4
5
# File 'lib/express_mailer/image.rb', line 3

def url
  @url
end

Class Method Details

.create(attrs) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/express_mailer/image.rb', line 5

def self.create(attrs)
  if attrs
    new(attrs)
  else
    nil
  end
end

Instance Method Details

#height ⇒ Object



25
26
27
# File 'lib/express_mailer/image.rb', line 25

def height
  @size.to_sym == :large ? 240 : 120
end

#shape_class ⇒ Object



21
22
23
# File 'lib/express_mailer/image.rb', line 21

def shape_class
  "shape-#{shape}"
end