Class: Termin::ANSIColor::PPMReader
- Inherits:
-
Object
- Object
- Termin::ANSIColor::PPMReader
show all
- Includes:
- Termin::ANSIColor
- Defined in:
- lib/termin/ansicolor/ppm_reader.rb
Constant Summary
ATTRIBUTE_NAMES, COLORED_REGEXP, VERSION, VERSION_ARRAY, VERSION_BUILD, VERSION_MAJOR, VERSION_MINOR
Instance Method Summary
collapse
attributes, #color, coloring=, coloring?, create_color_method, #on_color, #support?, term_ansicolor_attributes, #term_ansicolor_attributes, #uncolor
Constructor Details
#initialize(io, options = {}) ⇒ PPMReader
Returns a new instance of PPMReader.
6
7
8
9
10
|
# File 'lib/termin/ansicolor/ppm_reader.rb', line 6
def initialize(io, options = {})
@io = io
@options = options
@buffer = ''
end
|
Instance Method Details
#each_row ⇒ Object
20
21
22
23
24
25
|
# File 'lib/termin/ansicolor/ppm_reader.rb', line 20
def each_row
reset_io
@height.times do
yield parse_row
end
end
|
#reset_io ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/termin/ansicolor/ppm_reader.rb', line 12
def reset_io
begin
@io.rewind
rescue Errno::ESPIPE
end
end
|
#to_a ⇒ Object
27
28
29
|
# File 'lib/termin/ansicolor/ppm_reader.rb', line 27
def to_a
enum_for(:each_row).to_a
end
|
#to_s ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/termin/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
|