Sha256: 6d6730c9505357f647915ac3b671ba861c0ab13c84b5477a1125c05066f1b6df
Contents?: true
Size: 565 Bytes
Versions: 3
Compression:
Stored size: 565 Bytes
Contents
module RevealCK module Changers # # Public: A Slicer knows how to remove a section of a file. # class Slicer def self.remove!(slice_file, range) lines = File.open(slice_file).readlines slicer = Slicer.new lines sliced_lines = slicer.remove range File.open(slice_file, 'w') { |file| file << sliced_lines.join } end def initialize(lines) @lines = lines end def remove(range) @lines.select.with_index { |line, index| ! range.cover? index } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
reveal-ck-0.2.0 | lib/reveal-ck/changers/slicer.rb |
reveal-ck-0.1.8 | lib/reveal-ck/changers/slicer.rb |
reveal-ck-0.1.7 | lib/reveal-ck/changers/slicer.rb |