Class: TTYHue::Parser::StyleTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/ttyhue/parser/style_tag.rb

Instance Method Summary collapse

Methods inherited from Tag

#closing, #valid?

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_nameObject



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_nameObject



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

#regexpObject



5
6
7
# File 'lib/ttyhue/parser/style_tag.rb', line 5

def regexp
  /{(?<closing>\/?)(?<name>#{@styles.keys.map(&:to_s).join("|")})}/
end