Module: Rush::HeadTail

Included in:
Array, String
Defined in:
lib/rush/head_tail.rb

Overview

Mixin for array and string for methods I wish they had.

Instance Method Summary collapse

Instance Method Details

#head(n) ⇒ Object



3
4
5
# File 'lib/rush/head_tail.rb', line 3

def head(n)
	slice(0, n)
end

#tail(n) ⇒ Object



7
8
9
10
# File 'lib/rush/head_tail.rb', line 7

def tail(n)
	n = [ n, length ].min
	slice(-n, n)
end