class MemDB::Idx::Chars::ReversedChars

Public Class Methods

new(str) click to toggle source
# File lib/mem_db/idx/chars.rb, line 44
def initialize(str)
  @str = str
  @length = str.length
end

Public Instance Methods

[](pos) click to toggle source
# File lib/mem_db/idx/chars.rb, line 49
def [](pos)
  @str[@str.length - pos - 1]
end
each() { |str| ... } click to toggle source
# File lib/mem_db/idx/chars.rb, line 61
def each
  return to_enum unless block_given?

  i = @length - 1
  while i >= 0
    yield @str[i]
    i -= 1
  end
end
length() click to toggle source
# File lib/mem_db/idx/chars.rb, line 53
def length
  @str.length
end
reverse() click to toggle source
# File lib/mem_db/idx/chars.rb, line 57
def reverse
  Chars.new(@str)
end