Class: Style
- Inherits:
-
Object
- Object
- Style
- Defined in:
- lib/style.rb
Constant Summary collapse
- @@re_color =
Regexp.new(/^#(([0-9a-fA-F]{6})|([0-9a-fA-F]{3}))$/)
Instance Method Summary collapse
- #color(color) ⇒ Object
- #font ⇒ Object
- #font=(font) ⇒ Object
-
#initialize ⇒ Style
constructor
A new instance of Style.
- #set_color(color, value) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Style
Returns a new instance of Style.
3 4 5 6 7 8 9 10 |
# File 'lib/style.rb', line 3 def initialize @colors = { :bg => "#202020", :fg => "#757575", :bg_hi => "#303030", :fg_hi => "#FECF35" } end |
Instance Method Details
#color(color) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/style.rb', line 22 def color color unless @colors.keys.include? color raise ArgumentError, "Invalid key!" end @colors[color] end |
#font ⇒ Object
38 39 40 |
# File 'lib/style.rb', line 38 def font @font end |
#font=(font) ⇒ Object
29 30 31 |
# File 'lib/style.rb', line 29 def font= font @font = font end |
#set_color(color, value) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/style.rb', line 12 def set_color color, value unless @colors.keys.include? color raise ArgumentError, "Invalid key!" end unless @@re_color.match value raise ArgumentError, "Invalid color string!" end @colors[color] = value end |
#to_s ⇒ Object
32 33 34 35 36 |
# File 'lib/style.rb', line 32 def to_s string = "" string = @font unless @font.nil? string += " #{@colors}" end |