lib/ronin/formatting/extensions/text/string.rb in ronin-0.1.0 vs lib/ronin/formatting/extensions/text/string.rb in ronin-0.1.1

- old
+ new

@@ -37,18 +37,23 @@ def format_chars(options={},&block) included = (options[:included] || Ronin::Chars.all) excluded = (options[:excluded] || []) formatted = included - excluded + formatted = '' - return self.scan(/./m).map { |c| + self.each_byte do |b| + c = b.chr + if formatted.include?(c) - block.call(c) + formatted_chars << block.call(c) else - c + formatted_chars << c end - }.join + end + + return formatted end # # Creates a new String by passing each byte to the specified _block_ # using the given _options_. @@ -79,10 +84,10 @@ # case changed; defaults to 0.5. # # "get out your checkbook".rand_case # # => "gEt Out YOur CHEckbook" # - def rand_case(options={}) + def random_case(options={}) prob = (options[:probability] || 0.5) format_chars(options) do |c| if rand < prob c.swapcase