Class: Wasko::Palette::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/wasko/palette.rb

Direct Known Subclasses

Original, Plain

Instance Method Summary collapse

Constructor Details

#initialize(color_string, contrast = 0) ⇒ Base

Takes a valid css color string and an optional contrast argument. The contrast is useful to tweak the output of things.

It sets a base color ‘@base` and creates a color palette derived from the base color using the `colors!` method.



13
14
15
16
17
18
19
# File 'lib/wasko/palette.rb', line 13

def initialize(color_string, contrast = 0)
  @colors = {}
  @base = Wasko::Color.color_from_string(color_string)
  @base = white unless @base
  @contrast = 30 + contrast
  colors!
end

Instance Method Details

#ansi_colors?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/wasko/palette.rb', line 31

def ansi_colors?
  p.colors[:yellow]
end

#blackObject

Returns a ‘color`-instance of black



27
28
29
# File 'lib/wasko/palette.rb', line 27

def black
  Wasko::Color.color_from_string("black")
end

#whiteObject

Returns a ‘color`-instance of white



22
23
24
# File 'lib/wasko/palette.rb', line 22

def white
  Wasko::Color.color_from_string("white")
end