Class: RD::Part

### Home Classes Methods

### In Files

- lib/rd/filter.rb

### Parent

Object

### Methods

- ::new
- #<<
- #each
- #each_byte
- #each_line
- #empty?
- #eof
- #eof?
- #getc
- #gets
- #print
- #printf
- #putc
- #puts
- #read
- #readchar
- #readline
- #readlines
- #rewind
- #seek
- #to_s
- #ungetc
- #write

### Files

- post-install

### Class/Module Index

Quicksearch

- RD
- RD::AutoLabel
- RD::BlockElement
- RD::Code
- RD::ComplexListItem
- RD::DescList
- RD::DescListItem
- RD::DescListItem::Term
- RD::DocumentElement
- RD::DocumentStructure
- RD::Element
- RD::ElementRelationship
- RD::Emphasis
- RD::EnumList
- RD::EnumListItem
- RD::Filter
- RD::Filter::FileInclude
- RD::Footnote
- RD::Headline
- RD::Include
- RD::Index
- RD::InlineElement
- RD::InlineIncludable
- RD::ItemList
- RD::ItemListItem
- RD::Keyboard
- RD::LabelComposable
- RD::LabeledElement
- RD::List
- RD::ListItem
- RD::ListItemComposable
- RD::MethodList
- RD::MethodListItem
- RD::MethodListItem::Term
- RD::MethodParse
- RD::NonterminalElement
- RD::NonterminalInline
- RD::OutputFormatVisitor
- RD::ParserUtility
- RD::Part
- RD::RBLFile
- RD::RBLSuite
- RD::RD2HTMLExtVisitor
- RD::RD2HTMLExtVisitor::EnableBr
- RD::RD2HTMLExtVisitor::HeadElement
- RD::RD2HTMLExtVisitor::HeadLineTitle
- RD::RD2HTMLExtVisitor::HeadlineSecno
- RD::RD2HTMLExtVisitor::NativeInline
- RD::RD2HTMLExtVisitor::RefExtension
- RD::RD2HTMLVisitor
- RD::RD2MANVisitor
- RD::RD2RDOVisitor
- RD::RD2RMIVisitor
- RD::RDElement
- RD::RDInlineParser
- RD::RDParser
- RD::RDTree
- RD::RDVisitor
- RD::Reference
- RD::Reference::Label
- RD::Reference::RDLabel
- RD::Reference::TemporaryLabel
- RD::Reference::URL
- RD::ReferenceResolver
- RD::SearchFile
- RD::StringElement
- RD::TerminalElement
- RD::TerminalInline
- RD::TextBlock
- RD::Tree
- RD::Var
- RD::Verb
- RD::Verbatim
- RD::Version
- RD::Visitor
- Array

No matching classes.

# RD::Part

RD::Part is a pseudo IO class

### Attributes

lineno[RW]
pos[RW]
tell[RW]
tree[R]

### Public Class Methods

new(content = "", tree = nil, mode = "r") click to toggle source

    # File lib/rd/filter.rb, line 74
    def initialize(content = "", tree = nil, mode = "r")
      @content = content
      if mode == "r"
        @content.freeze
      end
      @tree = tree
      @pos = 0
      @lineno = 0
      @unget = nil
    end

### Public Instance Methods

<<(arg) click to toggle source

    # File lib/rd/filter.rb, line 195
    def << (arg)
      begin
        @content << arg.to_s
        self
      rescue
        raise IOError
      end
    end

each(rs = $/) click to toggle source
Alias for: each_line
each_byte() click to toggle source

    # File lib/rd/filter.rb, line 92
    def each_byte
      while char = getc
        yield(char)
      end
    end

each_line(rs = $/) click to toggle source

    # File lib/rd/filter.rb, line 85
    def each_line(rs = $/)
      while line = gets
        yield(line)
      end
    end

Also aliased as: each
empty?() click to toggle source

    # File lib/rd/filter.rb, line 241
    def empty?
      @content.empty?
    end

eof() click to toggle source
Alias for: eof?
eof?() click to toggle source

    # File lib/rd/filter.rb, line 98
    def eof?
      @pos == @content.size
    end

Also aliased as: eof
getc() click to toggle source

    # File lib/rd/filter.rb, line 119
    def getc
      get_char(nil)
    end

gets(rs = $/) click to toggle source

    # File lib/rd/filter.rb, line 152
    def gets(rs = $/)
      get_line(nil, rs)
    end

print(*args) click to toggle source

    # File lib/rd/filter.rb, line 204
    def print(*args)
      begin
        args.each do |i|
          @content << i.to_s
        end
        nil
      rescue
        raise IOError
      end
    end

printf(format, *args) click to toggle source

    # File lib/rd/filter.rb, line 215
    def printf(format, *args)
      str = sprintf(format, *args)
      begin
        @content << str
        nil
      rescue
        raise IOError
      end
    end

putc(char) click to toggle source

    # File lib/rd/filter.rb, line 225
    def putc(char)
      self.printf("%c", char)
      char
    end

puts(*args) click to toggle source

    # File lib/rd/filter.rb, line 230
    def puts(*args)
      args.flatten.each do |i|
        self.print(i, "\n")
      end
    end

read(length = @content.size - @pos) click to toggle source

    # File lib/rd/filter.rb, line 160
    def read(length = @content.size - @pos)
      ret = ""
      length.times do
        ret << getc
      end
      ret
    end

readchar() click to toggle source

    # File lib/rd/filter.rb, line 123
    def readchar
      get_char(true)
    end

readline(rs = $/) click to toggle source

    # File lib/rd/filter.rb, line 156
    def readline(rs = $/)
      get_line(true, $/)
    end

readlines(rs = $/) click to toggle source

    # File lib/rd/filter.rb, line 168
    def readlines(rs = $/)
      ret = []
      each_line(rs) do |line|
        ret.push(line)
      end
      ret
    end

rewind() click to toggle source

    # File lib/rd/filter.rb, line 176
    def rewind
      @pos = 0
    end

seek(offset, whence) click to toggle source

    # File lib/rd/filter.rb, line 180
    def seek(offset, whence)
      case whence
      when 0
        @pos = offset
      when 1
        @pos += offset
      when 2
        @pos += @content.size - 1
      else
        raise Errno::EINVAL
      end
    end

to_s() click to toggle source

    # File lib/rd/filter.rb, line 245
    def to_s
      @content
    end

ungetc(char) click to toggle source

    # File lib/rd/filter.rb, line 127
    def ungetc(char)
      @ungetc = char
      nil
    end

write(str) click to toggle source

    # File lib/rd/filter.rb, line 236
    def write(str)
      @content << str.to_s
      str.to_s.size
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.