Class: EscapeCode::SgrState
- Inherits:
-
Object
- Object
- EscapeCode::SgrState
- Defined in:
- lib/escape_code/sgr_state.rb
Instance Attribute Summary collapse
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#bold ⇒ Object
(also: #bold?)
readonly
Returns the value of attribute bold.
-
#foreground ⇒ Object
readonly
Returns the value of attribute foreground.
Instance Method Summary collapse
- #ingest(command) ⇒ Object
-
#initialize ⇒ SgrState
constructor
A new instance of SgrState.
Constructor Details
#initialize ⇒ SgrState
Returns a new instance of SgrState.
6 7 8 9 10 |
# File 'lib/escape_code/sgr_state.rb', line 6 def initialize @bold = false @foreground = nil @background = nil end |
Instance Attribute Details
#background ⇒ Object (readonly)
Returns the value of attribute background.
3 4 5 |
# File 'lib/escape_code/sgr_state.rb', line 3 def background @background end |
#bold ⇒ Object (readonly) Also known as: bold?
Returns the value of attribute bold.
3 4 5 |
# File 'lib/escape_code/sgr_state.rb', line 3 def bold @bold end |
#foreground ⇒ Object (readonly)
Returns the value of attribute foreground.
3 4 5 |
# File 'lib/escape_code/sgr_state.rb', line 3 def foreground @foreground end |
Instance Method Details
#ingest(command) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/escape_code/sgr_state.rb', line 12 def ingest(command) # convenience thing to allow passing in an entire code instead of individual SGR commands if command.is_a?(EscapeCode::Code) command.sgr_commands.each { |c| ingest(c) } if command.sgr? return end if command.reset? @bold = false @foreground = nil @background = nil elsif command.bold? @bold = true elsif command.foreground_color? @foreground = command.color elsif command.background_color? @background = command.color end end |