In Files

Parent

Class/Module Index [+]

Quicksearch

HikiDoc::LineInput

Public Class Methods

new(f) click to toggle source
# File lib/hikidoc.rb, line 766
def initialize(f)
  @input = f
  @buf = []
  @lineno = 0
  @eof_p = false
end

Public Instance Methods

break(re) click to toggle source
Alias for: getlines_until
each() click to toggle source
# File lib/hikidoc.rb, line 845
def each
  while line = gets()
    yield line
  end
end
eof?() click to toggle source
# File lib/hikidoc.rb, line 777
def eof?
  @eof_p
end
getblock(term_re) click to toggle source
# File lib/hikidoc.rb, line 901
def getblock(term_re)
  buf = []
  until_terminator(term_re) do |line|
    buf.push line
  end
  buf
end
getlines_until(re) click to toggle source
# File lib/hikidoc.rb, line 883
def getlines_until(re)
  buf = []
  until_match(re) do |line|
    buf.push line
  end
  buf
end
Also aliased as: break
getlines_while(re) click to toggle source
# File lib/hikidoc.rb, line 862
def getlines_while(re)
  buf = []
  while_match(re) do |line|
    buf.push line
  end
  buf
end
Also aliased as: span
gets() click to toggle source
# File lib/hikidoc.rb, line 785
def gets
  unless @buf.empty?
    @lineno += 1
    return @buf.pop
  end
  return nil if @eof_p   # to avoid ARGF blocking.
  line = @input.gets
  line = line.sub(/\r\n/, "\n") if line
  @eof_p = line.nil?
  @lineno += 1
  line
end
gets_if(re) click to toggle source
# File lib/hikidoc.rb, line 827
def gets_if(re)
  line = gets()
  if not line or not (re =~ line)
    ungets line
    return nil
  end
  line
end
gets_unless(re) click to toggle source
# File lib/hikidoc.rb, line 836
def gets_unless(re)
  line = gets()
  if not line or re =~ line
    ungets line
    return nil
  end
  line
end
inspect() click to toggle source
# File lib/hikidoc.rb, line 773
def inspect
  "\#<#{self.class} file=#{@input.inspect} line=#{lineno()}>"
end
lineno() click to toggle source
# File lib/hikidoc.rb, line 781
def lineno
  @lineno
end
next?() click to toggle source
# File lib/hikidoc.rb, line 811
def next?
  peek() ? true : false
end
peek() click to toggle source
# File lib/hikidoc.rb, line 805
def peek
  line = gets()
  ungets line if line
  line
end
skip_blank_lines() click to toggle source
# File lib/hikidoc.rb, line 815
def skip_blank_lines
  n = 0
  while line = gets()
    unless line.strip.empty?
      ungets line
      return n
    end
    n += 1
  end
  n
end
span(re) click to toggle source
Alias for: getlines_while
ungets(line) click to toggle source
# File lib/hikidoc.rb, line 798
def ungets(line)
  return unless line
  @lineno -= 1
  @buf.push line
  line
end
until_match(re) click to toggle source
# File lib/hikidoc.rb, line 872
def until_match(re)
  while line = gets()
    if re =~ line
      ungets line
      return
    end
    yield line
  end
  nil
end
until_terminator(re) click to toggle source
# File lib/hikidoc.rb, line 893
def until_terminator(re)
  while line = gets()
    return if re =~ line   # discard terminal line
    yield line
  end
  nil
end
while_match(re) click to toggle source
# File lib/hikidoc.rb, line 851
def while_match(re)
  while line = gets()
    unless re =~ line
      ungets line
      return
    end
    yield line
  end
  nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.