Class: Traptcha::Image

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

Direct Known Subclasses

WaveImage

Instance Method Summary collapse

Constructor Details

#initialize(text, options = {}) ⇒ Image

Returns a new instance of Image.



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

def initialize(text, options = {})
  @text = text
  @canvas = ::Magick::Image.new(Traptcha.default_width, Traptcha.default_height)
  @canvas.format = "PNG"
  @options = options
end

Instance Method Details

#outputObject



16
17
18
19
# File 'lib/traptcha/image.rb', line 16

def output
  generate
  @canvas
end

#save(path) ⇒ Object



12
13
14
# File 'lib/traptcha/image.rb', line 12

def save(path)
  output.write(File.join(path, @text + ".png"))
end