Class: Passcard::Palette
- Inherits:
-
Object
- Object
- Passcard::Palette
- Extended by:
- Forwardable
- Defined in:
- lib/passcard/palette.rb
Constant Summary collapse
- GOLDEN_RATIO =
(1 + Math.sqrt(5))/2
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type = :passcard, options = {}) ⇒ Palette
constructor
A new instance of Palette.
- #list_types ⇒ Object
- #update_colors ⇒ Object
Constructor Details
#initialize(type = :passcard, options = {}) ⇒ Palette
Returns a new instance of Palette.
9 10 11 12 |
# File 'lib/passcard/palette.rb', line 9 def initialize(type = :passcard, = {}) self.type = type self. = end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
6 7 8 |
# File 'lib/passcard/palette.rb', line 6 def colors @colors end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/passcard/palette.rb', line 6 def end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/passcard/palette.rb', line 6 def type @type end |
Instance Method Details
#list_types ⇒ Object
37 38 39 40 41 |
# File 'lib/passcard/palette.rb', line 37 def list_types self.methods.map do |method| method.to_s.gsub!(/^generate_colors_/, '') end.compact.map(&:to_sym) end |
#update_colors ⇒ Object
30 31 32 33 34 35 |
# File 'lib/passcard/palette.rb', line 30 def update_colors return unless type && @colors = send("generate_colors_#{type}", ).map do |rgb| { color: rgb, text_color: readable_text_color_for(rgb) } end end |