Class: TRMNL::API::Models::Palette

Inherits:
Struct
  • Object
show all
Defined in:
lib/trmnl/api/models/palette.rb

Overview

Models the data of the API response.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePalette

Returns a new instance of Palette.



15
16
17
18
19
20
# File 'lib/trmnl/api/models/palette.rb', line 15

def initialize(**)
  super
  self[:grays] ||= 0
  self[:colors] ||= Core::EMPTY_ARRAY
  freeze
end

Instance Attribute Details

#colorsObject

Returns the value of attribute colors

Returns:

  • (Object)

    the current value of colors



10
11
12
# File 'lib/trmnl/api/models/palette.rb', line 10

def colors
  @colors
end

#framework_classObject

Returns the value of attribute framework_class

Returns:

  • (Object)

    the current value of framework_class



10
11
12
# File 'lib/trmnl/api/models/palette.rb', line 10

def framework_class
  @framework_class
end

#graysObject

Returns the value of attribute grays

Returns:

  • (Object)

    the current value of grays



10
11
12
# File 'lib/trmnl/api/models/palette.rb', line 10

def grays
  @grays
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



10
11
12
# File 'lib/trmnl/api/models/palette.rb', line 10

def label
  @label
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



10
11
12
# File 'lib/trmnl/api/models/palette.rb', line 10

def name
  @name
end

Class Method Details

.for(attributes) ⇒ Object



13
# File 'lib/trmnl/api/models/palette.rb', line 13

def self.for(attributes) = new(**attributes.transform_keys(name: :label, id: :name))