class Minitest::Heat::Output::Token
Constants
- COLORS
- END_SEQUENCE
- ESC_SEQUENCE
- STYLES
- WEIGHTS
Attributes
content[RW]
style_key[RW]
Public Class Methods
new(style_key, content)
click to toggle source
# File lib/minitest/heat/output/token.rb, line 25 def initialize(style_key, content) @style_key = style_key @content = content end
Public Instance Methods
eql?(other)
click to toggle source
# File lib/minitest/heat/output/token.rb, line 40 def eql?(other) style_key == other.style_key && content == other.content end
Also aliased as: ==
to_s(format = :styled)
click to toggle source
# File lib/minitest/heat/output/token.rb, line 30 def to_s(format = :styled) return content unless format == :styled [ style_string, content, reset_string ].join end
Private Instance Methods
color()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 89 def color COLORS.fetch(color_key) end
color_key()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 81 def color_key style_components[1] end
reset_string()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 73 def reset_string "#{ESC_SEQUENCE}0#{END_SEQUENCE}" end
style_components()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 93 def style_components STYLES.fetch(style_key) { raise InvalidStyle, "'#{style_key}' is not a valid style option for tokens" } end
style_string()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 69 def style_string "#{ESC_SEQUENCE}#{weight};#{color}#{END_SEQUENCE}" end
weight()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 85 def weight WEIGHTS.fetch(weight_key) end
weight_key()
click to toggle source
# File lib/minitest/heat/output/token.rb, line 77 def weight_key style_components[0] end