Class: TTYHue::Parser::StyleTag
- Defined in:
- lib/ttyhue/parser/style_tag.rb
Instance Method Summary collapse
- #bg_color_name ⇒ Object
- #fg_color_name ⇒ Object
-
#initialize(str, styles = {}) ⇒ StyleTag
constructor
A new instance of StyleTag.
- #regexp ⇒ Object
Methods inherited from Tag
Constructor Details
#initialize(str, styles = {}) ⇒ StyleTag
Returns a new instance of StyleTag.
9 10 11 12 |
# File 'lib/ttyhue/parser/style_tag.rb', line 9 def initialize(str, styles = {}) @styles = styles super(str) end |
Instance Method Details
#bg_color_name ⇒ Object
18 19 20 |
# File 'lib/ttyhue/parser/style_tag.rb', line 18 def bg_color_name TermColor.by_tag(styles_hash[:bg].to_s)&.color_name end |
#fg_color_name ⇒ Object
14 15 16 |
# File 'lib/ttyhue/parser/style_tag.rb', line 14 def fg_color_name TermColor.by_tag(styles_hash[:fg].to_s)&.color_name end |
#regexp ⇒ Object
5 6 7 |
# File 'lib/ttyhue/parser/style_tag.rb', line 5 def regexp /{(?<closing>\/?)(?<name>#{@styles.keys.map(&:to_s).join("|")})}/ end |