Class: Style
- Inherits:
-
Object
- Object
- Style
- Defined in:
- lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#description ⇒ Object
Returns the value of attribute description.
-
#font ⇒ Object
Returns the value of attribute font.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node_id ⇒ Object
Returns the value of attribute node_id.
-
#style_type ⇒ Object
Returns the value of attribute style_type.
Class Method Summary collapse
Instance Method Summary collapse
- #description_params ⇒ Object
-
#initialize(name:, node_id:, style_type:, description:, color: nil, font: nil) ⇒ Style
constructor
A new instance of Style.
- #is_dark ⇒ Object
- #name_info ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name:, node_id:, style_type:, description:, color: nil, font: nil) ⇒ Style
Returns a new instance of Style.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 55 def initialize( name:, node_id:, style_type:, description:, color: nil, font: nil ) @name = name @node_id = node_id @style_type = style_type @description = description @color = color @font = font end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
47 48 49 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 47 def color @color end |
#description ⇒ Object
Returns the value of attribute description.
47 48 49 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 47 def description @description end |
#font ⇒ Object
Returns the value of attribute font.
47 48 49 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 47 def font @font end |
#name ⇒ Object
Returns the value of attribute name.
47 48 49 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 47 def name @name end |
#node_id ⇒ Object
Returns the value of attribute node_id.
47 48 49 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 47 def node_id @node_id end |
#style_type ⇒ Object
Returns the value of attribute style_type.
47 48 49 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 47 def style_type @style_type end |
Class Method Details
.from_hash(hash) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 79 def self.from_hash(hash) return nil if hash.nil? name = hash['name'] node_id = hash['node_id'] style_type = hash['style_type'] description = hash['description'] color_hash = hash['color'] font_hash = hash['font'] color = !color_hash.nil? ? Color.from_hash(color_hash) : nil font = !font_hash.nil? ? Font.from_hash(font_hash) : nil if !name.nil? && !node_id.nil? && style_type return Style.new(name: name, node_id: node_id, style_type: style_type, description: description, color: color, font: font) end nil end |
Instance Method Details
#description_params ⇒ Object
49 50 51 52 53 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 49 def description_params JSON.parse(description) rescue StandardError nil end |
#is_dark ⇒ Object
75 76 77 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 75 def is_dark name.downcase.include?('dark') || false end |
#name_info ⇒ Object
71 72 73 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 71 def name_info StyleNameInfo.create_from(name: name) end |
#to_hash ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/admiral-tools-figma/helper/figma/figma_client/models/domain/primitives/style.rb', line 100 def to_hash hash = {} hash['name'] = name hash['node_id'] = node_id hash['style_type'] = style_type hash['description'] = description hash['color'] = color&.to_hash unless color.nil? hash['font'] = font&.to_hash unless font.nil? hash['name_info'] = name_info.to_hash unless name_info.nil? hash['description_params'] = description_params unless description_params.nil? hash['is_dark'] = is_dark hash end |