class BEncode::Parser

Attributes

stream[R]

Public Instance Methods

eos?() click to toggle source
# File lib/bencode/parser.rb, line 27
def eos?
  stream.eof?
end
parse!() click to toggle source
# File lib/bencode/parser.rb, line 18
def parse!
  case peek
    when i then parse_integer!
    when l then parse_list!
    when d then parse_dict!
    when 0 .. 9 then parse_string!
  end
end

Public Class Methods

new(stream) click to toggle source
# File lib/bencode/parser.rb, line 7
def initialize(stream)
  @stream =
    if stream.kind_of?(IO) || stream.kind_of?(StringIO)
      stream
    elsif stream.respond_to? :string
      StringIO.new stream.string
    elsif stream.respond_to? :to_s
      StringIO.new stream.to_s
    end
end