Class: Array
Overview
Copyright 2010-2012 Tasos Laskos <[email protected]>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing and
limitations under the License.
Instance Method Summary collapse
- #chunk(pieces = 2) ⇒ Object
-
#includes_tags?(tags) ⇒ Bool
trueifselfcontains any of thetagswhen objects of bothselfandtagsare converted toString.
Instance Method Details
#chunk(pieces = 2) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/arachni/ruby/array.rb', line 34 def chunk( pieces = 2 ) return self if pieces <= 0 len = self.length mid = len / pieces chunks = [] start = 0 1.upto( pieces ) do |i| last = start + mid last = last - 1 unless len % pieces >= i chunks << self[ start..last ] || [] start = last + 1 end chunks end |
#includes_tags?(tags) ⇒ Bool
Returns true if self contains any of the tags when objects of both self and tags are converted to String.
25 26 27 28 29 30 31 32 |
# File 'lib/arachni/ruby/array.rb', line 25 def ( ) return false if ! = [].flatten.compact.map( &:to_s ) return false if .empty? (self.flatten.compact.map( &:to_s ) & ).any? end |