Code Coverage
 
Lines
Covered
100.00% covered (success)
100.00%
28 / 28
1
module TheFox
1
module TermKit
##
# Holds the character for a single Point of a View.
1
class ViewContent
1
attr_accessor :char
1
attr_accessor :view
# This variable is used to detect which of the points has already been rendered by the View.
#
# - If `true` View `render()` will return this instance.
# - If `false` the content of the View didn't change since the last call of `render()` and the content has already been used in `render()`.
1
attr_accessor :needs_rendering
1
attr_accessor :origin
1
attr_reader :foreground_color
1
attr_reader :background_color
1
def initialize(char, view = nil, origin = nil)
1431
@char = char[0]
1431
@view = view
1431
@needs_rendering = true
1431
@origin = origin
1431
@foreground_color = nil
1431
@background_color = nil
end
1
def foreground_color=(foreground_color)
104
if @foreground_color != foreground_color
104
@foreground_color = foreground_color
104
@needs_rendering = true
end
end
1
def background_color=(background_color)
104
if @background_color != background_color
104
@background_color = background_color
104
@needs_rendering = true
end
end
1
def to_s
4
@char
end
1
def inspect
20
"#<#{self.class.name.split('::').last} c='#{@char}' r?=#{@needs_rendering ? 'Y' : 'N'} v=#{@view} o=#{@origin}>"
end
end
end
end