Class: Gitlab::Ci::Ansi2json::Style
- Inherits:
-
Object
- Object
- Gitlab::Ci::Ansi2json::Style
- Defined in:
- lib/gitlab/ci/ansi2json/style.rb
Instance Attribute Summary collapse
-
#bg ⇒ Object
readonly
Returns the value of attribute bg.
-
#fg ⇒ Object
readonly
Returns the value of attribute fg.
-
#mask ⇒ Object
readonly
Returns the value of attribute mask.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(fg: nil, bg: nil, mask: 0) ⇒ Style
constructor
A new instance of Style.
- #reset! ⇒ Object
- #set? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
- #update(ansi_commands) ⇒ Object
Constructor Details
#initialize(fg: nil, bg: nil, mask: 0) ⇒ Style
Returns a new instance of Style.
9 10 11 12 13 14 15 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 9 def initialize(fg: nil, bg: nil, mask: 0) @fg = fg @bg = bg @mask = mask update_formats end |
Instance Attribute Details
#bg ⇒ Object (readonly)
Returns the value of attribute bg.
7 8 9 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 7 def bg @bg end |
#fg ⇒ Object (readonly)
Returns the value of attribute fg.
7 8 9 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 7 def fg @fg end |
#mask ⇒ Object (readonly)
Returns the value of attribute mask.
7 8 9 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 7 def mask @mask end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 35 def ==(other) self.to_h == other.to_h end |
#reset! ⇒ Object
28 29 30 31 32 33 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 28 def reset! @fg = nil @bg = nil @mask = 0 @formats = [] end |
#set? ⇒ Boolean
24 25 26 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 24 def set? @fg || @bg || @formats.any? end |
#to_h ⇒ Object
43 44 45 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 43 def to_h { fg: @fg, bg: @bg, mask: @mask } end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 39 def to_s [@fg, @bg, @formats].flatten.compact.join(' ') end |
#update(ansi_commands) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/gitlab/ci/ansi2json/style.rb', line 17 def update(ansi_commands) # treat e\[m as \e[0m ansi_commands = ['0'] if ansi_commands.empty? evaluate_stack_command(ansi_commands) end |