Class: FigmaPaint

Inherits:
Object
  • Object
show all
Defined in:
lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, color:, opacity:) ⇒ FigmaPaint

Returns a new instance of FigmaPaint.



8
9
10
11
12
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb', line 8

def initialize(type:, color:, opacity:)
  @type = type
  @color = color
  @opacity = opacity
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb', line 6

def color
  @color
end

#opacityObject

Returns the value of attribute opacity.



6
7
8
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb', line 6

def opacity
  @opacity
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb', line 6

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb', line 14

def self.from_hash(hash)
  return nil if hash.nil?

  type = hash['type']
  color = FigmaColor.from_hash(hash['color'])
  opacity = hash['opacity'] || 1.0

  return FigmaPaint.new(type: type, color: color, opacity: opacity) if !type.nil? && !color.nil?

  nil
end

Instance Method Details

#to_hashObject



26
27
28
29
30
31
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_paint.rb', line 26

def to_hash
  hash = {}
  hash['type'] = type
  hash['color'] = color.to_hash unless color.nil?
  hash
end