Class: PictureFrame::Frame
- Inherits:
-
Object
- Object
- PictureFrame::Frame
- Defined in:
- lib/picture_frame/frame.rb
Instance Method Summary collapse
- #frame(text) ⇒ Object
-
#initialize(template_string, options = {}) ⇒ Frame
constructor
A new instance of Frame.
Constructor Details
Instance Method Details
#frame(text) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/picture_frame/frame.rb', line 12 def frame(text) image = Image.new(text) Canvas.new(@template.bottom_right, image.dimensions).tap do |canvas| pp = placeholder_position return '' if pp.empty? r1, c1 = pp rn, cm = image.dimensions canvas.print_at(:tl, @template.slice_from(pp, :tl)) canvas.print_at(:tr, @template.slice_from(pp, :tr)) canvas.print_at(:br, @template.slice_from(pp, :br)) canvas.print_at(:bl, @template.slice_from(pp, :bl)) canvas.print_at(:t, @template.slice_from(pp, :t), c1, cm) canvas.print_at(:b, @template.slice_from(pp, :b), c1, cm) canvas.print_at(:l, @template.slice_from(pp, :l), r1, rn) canvas.print_at(:r, @template.slice_from(pp, :r), r1, rn) canvas.print_at(pp, image) end.to_s end |