class Slippery::Processors::ImpressJs::AutoOffsets
Public Class Methods
new(offset_x = 1000, offset_y = 0)
click to toggle source
# File lib/slippery/processors/impress_js/auto_offsets.rb, line 5 def initialize(offset_x = 1000, offset_y = 0) @offsets = [offset_x, offset_y] @position = [0,0] end
Public Instance Methods
call(doc)
click to toggle source
# File lib/slippery/processors/impress_js/auto_offsets.rb, line 10 def call(doc) doc.replace('.step') do |step| ['data-x', 'data-y'].each_with_index do |axis, idx| if step.has_attr?(axis) @position[idx] = step[axis].to_i else @position[idx] += @offsets[idx] end end step % { 'data-x' => @position[0], 'data-y' => @position[1] } end end