lib/vedeu/colours/foreground.rb in vedeu-0.8.2 vs lib/vedeu/colours/foreground.rb in vedeu-0.8.3
- old
+ new
@@ -15,10 +15,30 @@
# @return [Boolean]
def foreground?
present?(to_s)
end
+ # @return [Hash<Symbol => String>]
+ def to_h
+ {
+ foreground: colour.to_s
+ }
+ end
+ alias_method :to_hash, :to_h
+
+ # @param _options [Hash] Ignored.
+ # @return [String]
+ def to_html(_options = {})
+ if rgb?
+ "color:#{colour};"
+
+ else
+ ''
+
+ end
+ end
+
private
# @return [String]
def prefix
"\e[38;"
@@ -29,10 +49,10 @@
# @note
# Valid names can be found at
# {Vedeu::EscapeSequences::Esc#valid_codes}
#
# @return [String]
- def named_code
+ def named
Vedeu.esc.foreground_colour(colour)
end
# @return [Vedeu::Colours::Foregrounds]
def repository