Module: CryptBufferConcern::Array

Included in:
CryptBuffer
Defined in:
lib/crypto-toolbox/crypt_buffer/concerns/array.rb

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object



3
4
5
6
7
# File 'lib/crypto-toolbox/crypt_buffer/concerns/array.rb', line 3

def +(other)
  # make sure the input is a cryptbuffer
  # Thus we support cryptbuffers and byte arrays
  CryptBuffer(bytes + CryptBuffer(other).bytes)
end

#[](*things) ⇒ Object



25
26
27
# File 'lib/crypto-toolbox/crypt_buffer/concerns/array.rb', line 25

def [](*things)
  CryptBuffer(bytes[*things])
end

#first(n = 1) ⇒ Object



17
18
19
# File 'lib/crypto-toolbox/crypt_buffer/concerns/array.rb', line 17

def first(n = 1 )
  CryptBuffer(bytes.first(n))
end

#last(n = 1) ⇒ Object



21
22
23
# File 'lib/crypto-toolbox/crypt_buffer/concerns/array.rb', line 21

def last(n = 1)
  CryptBuffer(bytes.last(n))
end

#shift(n = 1) ⇒ Object



9
10
11
# File 'lib/crypto-toolbox/crypt_buffer/concerns/array.rb', line 9

def shift(n = 1)
  CryptBuffer(bytes.shift(n))
end

#unshift(anything) ⇒ Object



13
14
15
# File 'lib/crypto-toolbox/crypt_buffer/concerns/array.rb', line 13

def unshift(anything)
  CryptBuffer(bytes.unshift(anything))
end