Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/data_slicer.rb

Overview

monkey-patching to add a data_slice string extension method

Instance Method Summary collapse

Instance Method Details

#data_slice(*args) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/data_slicer.rb', line 3

def data_slice(*args)
  index = 0
  args.map do |length|
    start = index
    index += length
    slice(start, length).strip
  end
end