Class: Memerize

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemerize

Returns a new instance of Memerize.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/memerize.rb', line 8

def initialize
  self.memes = {
    :cao => "/cao_base.jpg",
    :fry => "/fry_base.jpg",
    :yuno => "/yuno_base.jpg",
    :falone => "/falone_base.jpg",
    :successkid => "/successkid_base.jpg",
    :facebookgirl => "/facebookgirl_base.jpg"
  }
  self.meme_name = ARGV[0]
  self.text_top = ARGV[1]
  self.text_footer = ARGV[2]
  create_meme()
end

Instance Attribute Details

#meme_nameObject

Returns the value of attribute meme_name.



6
7
8
# File 'lib/memerize.rb', line 6

def meme_name
  @meme_name
end

#memesObject

Returns the value of attribute memes.



6
7
8
# File 'lib/memerize.rb', line 6

def memes
  @memes
end

Returns the value of attribute text_footer.



6
7
8
# File 'lib/memerize.rb', line 6

def text_footer
  @text_footer
end

#text_topObject

Returns the value of attribute text_top.



6
7
8
# File 'lib/memerize.rb', line 6

def text_top
  @text_top
end

Instance Method Details

#create_memeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/memerize.rb', line 23

def create_meme()
  dir_images = File.expand_path(File.dirname(__FILE__) + '/../lib/images')
  image = ImageList.new(dir_images + @memes[@meme_name.to_sym])
  text = Draw.new
  text.pointsize = 46
  text.stroke = "black"
  text.stroke_width = 2
  text.fill = "white"
  text.font_family = "Impact-Normal"
  text.font_weight = BoldWeight

  text.annotate(image, 0, 0, 0, 9, self.text_top) {
    self.gravity = NorthGravity
  }
  text.annotate(image, 0, 0, 0, 9, self.text_footer) {
    self.gravity = SouthGravity
  }
  image.write("#{self.meme_name}.jpg")
end