Class: Term::ANSIColor::PPMReader

### Home Classes Methods

### In Files

- lib/term/ansicolor/ppm_reader.rb

### Parent

Object

### Methods

- ::new
- #each_row
- #reset_io
- #to_a
- #to_s

### Included Modules

- Term::ANSIColor

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Term
- Term::ANSIColor
- Term::ANSIColor::Attribute
- Term::ANSIColor::PPMReader
- Term::ANSIColor::RGBTriple

No matching classes.

# Term::ANSIColor::PPMReader

### Public Class Methods

new(io, options = {}) click to toggle source

    # File lib/term/ansicolor/ppm_reader.rb, line 6
    def initialize(io, options = {})
      @io      = io
      @options = options
      @buffer  = ''
    end

### Public Instance Methods

each_row() click to toggle source

    # File lib/term/ansicolor/ppm_reader.rb, line 20
    def each_row
      reset_io
      @height.times do
        yield parse_row
      end
    end

reset_io() click to toggle source

    # File lib/term/ansicolor/ppm_reader.rb, line 12
    def reset_io
      begin
        @io.rewind
      rescue Errno::ESPIPE
      end
      parse_header
    end

to_a() click to toggle source

    # File lib/term/ansicolor/ppm_reader.rb, line 27
    def to_a
      enum_for(:each_row).to_a
    end

to_s() click to toggle source

    # File lib/term/ansicolor/ppm_reader.rb, line 31
    def to_s
      result = ''
      each_row do |row|
        last_pixel = nil
        for pixel in row
          if pixel != last_pixel
            color = Attribute.nearest_rgb_color(pixel, @options)
            result << on_color(color)
            last_pixel = pixel
          end
          result << ' '
        end
        result << reset << "\n"
      end
      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.