Class: Jani::StripMaker::FrameList

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Magick
Defined in:
lib/jani/strip_maker/frame_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(images: []) ⇒ FrameList

Returns a new instance of FrameList.



11
12
13
# File 'lib/jani/strip_maker/frame_list.rb', line 11

def initialize(images: [])
  @images = images.dup
end

Instance Attribute Details

#imagesObject (readonly)

Returns the value of attribute images.



9
10
11
# File 'lib/jani/strip_maker/frame_list.rb', line 9

def images
  @images
end

Instance Method Details

#append_image(image) ⇒ Object



15
16
17
# File 'lib/jani/strip_maker/frame_list.rb', line 15

def append_image(image)
  @images << image
end

#append_image_with_filename(filename) ⇒ Object



19
20
21
# File 'lib/jani/strip_maker/frame_list.rb', line 19

def append_image_with_filename(filename)
  append_image(Image.read(filename)[0])
end

#to_stripsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jani/strip_maker/frame_list.rb', line 23

def to_strips
  [].tap do |strips|
    index = 1
    while !@images.empty?
      strip = Jani::StripMaker::Strip.new(index: index)
      until @images.empty? || strip.big_enough?
        strip.append_frame(@images.shift)
      end
      strips << strip
      index = index + 1
      next
    end
  end
end