Class: UnicodePlot::IOContext

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
src/lib/unicode_plot/io_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, color: :auto) ⇒ IOContext

Returns a new instance of IOContext.



7
8
9
10
# File 'src/lib/unicode_plot/io_context.rb', line 7

def initialize(io, color: :auto)
  @io = io
  @color = check_color(color)
end

Instance Method Details

#color?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
# File 'src/lib/unicode_plot/io_context.rb', line 14

def color?
  case @color
  when :auto
    @io.respond_to?(:tty?) ? @io.tty? : false
  else
    @color
  end
end