Class: ASEPalette::Color
- Inherits:
-
Object
- Object
- ASEPalette::Color
- Defined in:
- lib/ase-palette/color.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Name cannot changed once a color is created in order to protect the integrity of unique names in a palette.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#model ⇒ Object
Get color model.
-
#to_h ⇒ Object
Convert color to hash, necessary for binary representation.
-
#to_s ⇒ Object
Convert color to string.
Instance Attribute Details
#name ⇒ Object (readonly)
Name cannot changed once a color is created in order to protect the integrity of unique names in a palette
7 8 9 |
# File 'lib/ase-palette/color.rb', line 7 def name @name end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/ase-palette/color.rb', line 8 def type @type end |
Instance Method Details
#model ⇒ Object
Get color model
11 12 13 |
# File 'lib/ase-palette/color.rb', line 11 def model self.class.to_s.split('::').last.downcase.to_sym end |
#to_h ⇒ Object
Convert color to hash, necessary for binary representation
25 26 27 28 29 30 31 32 |
# File 'lib/ase-palette/color.rb', line 25 def to_h { name: @name, model: model, data: data, type: @type, } end |
#to_s ⇒ Object
Convert color to string
16 17 18 19 20 21 |
# File 'lib/ase-palette/color.rb', line 16 def to_s "#{@name}, " \ "#{model.upcase}: " \ "#{data.values.join("/")}, " \ ":#{@type}" end |