Class: PixelCurtain::Curtain

Inherits:
Object
  • Object
show all
Includes:
Magick
Defined in:
lib/pixel_curtain/curtain.rb

Direct Known Subclasses

SimpleCurtain

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Curtain

Returns a new instance of Curtain.



7
8
9
10
# File 'lib/pixel_curtain/curtain.rb', line 7

def initialize(file_path)
  @source_image = Image.read(file_path).first
  @output = Image.new(1440,900)
end

Instance Method Details

#process(options = {}) ⇒ Object

Do nothing, this is to be implemented by subclasses



13
14
15
# File 'lib/pixel_curtain/curtain.rb', line 13

def process(options = {})
  @output
end

#save(file_name, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pixel_curtain/curtain.rb', line 17

def save(file_name, options = {})
  
  options[:temp_file] = false if options[:temp_file].nil?
  
  if options[:temp_file]
    output_file = Tempfile.new(['pixel_curtain', 'png'])
  else
    output_file = File.new(file_name, 'w')
  end
  
  @output.write("png:" + output_file.path)
  
  return output_file
end