Class: Lgtmit::Compositer

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

Constant Summary collapse

POS =
"0, 0"
TEXT =
"LGTM"
COLOR =
"#ffffff"
GRAV =
"center"
FMT =
"png"
P_SCALE =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ Compositer

Returns a new instance of Compositer.



14
15
16
17
# File 'lib/lgtmit/compositer.rb', line 14

def initialize(file_name)
  @file_name = file_name
  @image = MiniMagick::Image.open(@file_name)
end

Instance Attribute Details

#file_nameObject

Returns the value of attribute file_name.



5
6
7
# File 'lib/lgtmit/compositer.rb', line 5

def file_name
  @file_name
end

#imageObject

Returns the value of attribute image.



5
6
7
# File 'lib/lgtmit/compositer.rb', line 5

def image
  @image
end

Instance Method Details

#configure_image!Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/lgtmit/compositer.rb', line 24

def configure_image!
  @image.combine_options do |config|
    config.fill COLOR
    config.gravity GRAV
    config.pointsize p_size_calc
    config.draw "text #{POS} '#{TEXT}'"
  end
  @image.format FMT
  @image
end

#runObject



19
20
21
22
# File 'lib/lgtmit/compositer.rb', line 19

def run
  configure_image!
  write_image!
end

#write_image!Object



35
36
37
# File 'lib/lgtmit/compositer.rb', line 35

def write_image!
  @image.write "#{TEXT}_#{Pathname.new(file_name).basename.to_s}"
end