Class: Slippery::Processors::ImpressJs::AutoOffsets
- Inherits:
-
Object
- Object
- Slippery::Processors::ImpressJs::AutoOffsets
- Defined in:
- lib/slippery/processors/impress_js/auto_offsets.rb
Instance Method Summary collapse
- #call(doc) ⇒ Object
-
#initialize(offset_x = 1000, offset_y = 0) ⇒ AutoOffsets
constructor
A new instance of AutoOffsets.
Constructor Details
#initialize(offset_x = 1000, offset_y = 0) ⇒ AutoOffsets
Returns a new instance of AutoOffsets.
5 6 7 8 |
# 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 |
Instance Method Details
#call(doc) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |