Class: Array
Overview
Copyright 2010-2014 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 permissions and
limitations under the License.
Instance Method Summary collapse
- #chunk(pieces = 2) ⇒ Object
-
#includes_tags?(tags) ⇒ Bool
‘true` if `self` contains any of the `tags` when objects of both `self` and `tags` are converted to `String`.
-
#recode ⇒ Array
Recursively converts the array’s string data to UTF8.
Instance Method Details
#chunk(pieces = 2) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/arachni/ruby/array.rb', line 43 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`.
26 27 28 29 30 31 32 33 |
# File 'lib/arachni/ruby/array.rb', line 26 def ( ) return false if ! = [].flatten.compact.map( &:to_s ) return false if .empty? (self.flatten.compact.map( &:to_s ) & ).any? end |
#recode ⇒ Array
Recursively converts the array’s string data to UTF8.
39 40 41 |
# File 'lib/arachni/ruby/array.rb', line 39 def recode map { |v| v.respond_to?( :recode ) ? v.recode : v } end |