Class: PaintbrushSupport::ColorElement
- Inherits:
-
Object
- Object
- PaintbrushSupport::ColorElement
- Defined in:
- lib/paintbrush_support/color_element.rb
Overview
Provides a substring enclosed in unique escape codes for later colorization when the full string has been created and all interpolation is completed. Adds itself to a provided stack of ColorElement objects on initialization.
Instance Attribute Summary collapse
-
#close_index ⇒ Object
Returns the value of attribute close_index.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#open_index ⇒ Object
Returns the value of attribute open_index.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
-
#initialize(stack:, code:, string:) ⇒ ColorElement
constructor
A new instance of ColorElement.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(stack:, code:, string:) ⇒ ColorElement
Returns a new instance of ColorElement.
11 12 13 14 15 16 17 |
# File 'lib/paintbrush_support/color_element.rb', line 11 def initialize(stack:, code:, string:) @stack = stack @code = code @string = string @index = stack.size stack << self end |
Instance Attribute Details
#close_index ⇒ Object
Returns the value of attribute close_index.
9 10 11 |
# File 'lib/paintbrush_support/color_element.rb', line 9 def close_index @close_index end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/paintbrush_support/color_element.rb', line 8 def code @code end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
8 9 10 |
# File 'lib/paintbrush_support/color_element.rb', line 8 def index @index end |
#open_index ⇒ Object
Returns the value of attribute open_index.
9 10 11 |
# File 'lib/paintbrush_support/color_element.rb', line 9 def open_index @open_index end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
8 9 10 |
# File 'lib/paintbrush_support/color_element.rb', line 8 def stack @stack end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
8 9 10 |
# File 'lib/paintbrush_support/color_element.rb', line 8 def string @string end |
Instance Method Details
#inspect ⇒ Object
23 24 25 |
# File 'lib/paintbrush_support/color_element.rb', line 23 def inspect "<#{self.class.name} index=#{index} code=#{code}>" end |