Class: FigmaNode

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, type:, style:, fills:) ⇒ FigmaNode

Returns a new instance of FigmaNode.



9
10
11
12
13
14
15
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_node.rb', line 9

def initialize(id:, name:, type:, style:, fills:)
  @id = id
  @name = name
  @type = type
  @style = style
  @fills = fills
end

Instance Attribute Details

#fillsObject

Returns the value of attribute fills.



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

def fills
  @fills
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#styleObject

Returns the value of attribute style.



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

def style
  @style
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_node.rb', line 17

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

  id = hash['id']
  name = hash['name']
  type = hash['type']
  style_hash = hash['style']
  style = style_hash.nil? ? nil : FigmaTypeStyle.from_hash(style_hash)
  fills = (hash['fills'] || []).map { |f| FigmaPaint.from_hash(f) }.compact || []

  if !id.nil? && !name.nil? && !type.nil?
    return FigmaNode.new(id: id, name: name, type: type, style: style, fills: fills)
  end

  nil
end

Instance Method Details

#to_hashObject



34
35
36
37
38
39
40
41
42
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/api/primitives/figma_node.rb', line 34

def to_hash
  hash = {}
  hash['id'] = id
  hash['name'] = name
  hash['type'] = type
  hash['style'] = style.to_hash unless style.nil?
  hash['fills'] = (fills || []).map(&:to_hash)
  hash
end