asciinema.org/app/models/brush.rb

65 lines
889 B
Ruby
Raw Normal View History

2013-07-10 06:45:17 +00:00
class Brush
def initialize(attributes = {})
@attributes = attributes.symbolize_keys
end
def ==(other)
fg == other.fg &&
bg == other.bg &&
bold? == other.bold? &&
underline? == other.underline? &&
inverse? == other.inverse? &&
blink? == other.blink?
2013-07-10 06:45:17 +00:00
end
def fg
code = attributes[:fg]
if code
if code < 8 && bold?
code += 8
end
end
code
2013-07-10 06:45:17 +00:00
end
def bg
code = attributes[:bg]
if code
if code < 8 && blink?
code += 8
end
end
code
2013-07-10 06:45:17 +00:00
end
def bold?
!!attributes[:bold]
end
def underline?
!!attributes[:underline]
end
def inverse?
!!attributes[:inverse]
end
def blink?
!!attributes[:blink]
end
def default?
fg.nil? && bg.nil? && !bold? && !underline? && !inverse? && !blink?
end
protected
attr_reader :attributes
2013-07-10 06:45:17 +00:00
end