Skip to content
Permalink
Browse files

Merge pull request #638 from kachick/implement-string-each_byte

Implement String#each_byte, String#bytes
  • Loading branch information
alex committed Apr 20, 2013
2 parents 47f5550 + 53c1790 commit 89a38bd5efc92b58f40ec30a36e4bc4cc0907de2
Showing with 14 additions and 3 deletions.
  1. +14 −0 lib-topaz/string.rb
  2. +0 −3 spec/tags/core/string/each_byte_tags.txt
@@ -116,6 +116,20 @@ def each_char(&block)
end
alias chars each_char

def each_byte(&block)
return self.enum_for(:each_byte) unless block

i = 0
limit = self.length
while i < limit
yield self.getbyte(i)
i += 1
end

self
end
alias bytes each_byte

def upto(max, exclusive = false, &block)
return self.enum_for(:upto, max, exclusive) unless block

@@ -1,4 +1 @@
fails:String#each_byte passes each byte in self to the given block
fails:String#each_byte keeps iterating from the old position (to new string end) when self changes
fails:String#each_byte returns self
fails:String#each_byte returns an enumerator when no block given

0 comments on commit 89a38bd

Please sign in to comment.
You can’t perform that action at this time.