Class: Array
Ronin - A Ruby platform for exploit development and security research.
Copyright © 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Public Visibility
Public Instance Method Summary
| #bytes |
Decodes the bytes contained within the Array. Returns: Array |
|---|---|
| #char_string |
Returns: String |
| #chars |
Decodes the characters contained within the Array. Returns: Array |
| #power_set |
Calculates the power-set of the Array. Returns: Array |
Public Instance Method Details
bytes
Decodes the bytes contained within the Array. The Array may contain both Integer and String objects.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ronin/formatting/extensions/text/array.rb', line 38 def bytes self.inject([]) do |accum,elem| if elem.kind_of?(Integer) accum << elem else elem.to_s.each_byte { |b| accum << b } end accum end end |
char_string
73 74 75 |
# File 'lib/ronin/formatting/extensions/text/array.rb', line 73 def char_string chars.join end |
chars
Decodes the characters contained within the Array. The Array may contain either Integer or String objects.
61 62 63 |
# File 'lib/ronin/formatting/extensions/text/array.rb', line 61 def chars self.bytes.map { |b| b.chr } end |
power_set
Calculates the power-set of the Array.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ronin/extensions/array.rb', line 35 def power_set inject([[]]) do |power_set,element| sub_set = [] power_set.each do |i| sub_set << i sub_set << i + [element] end sub_set end end |