gpt4 book ai didi

ruby - 如何将所有图标嵌入到一个数组中?

转载 作者:太空宇宙 更新时间:2023-11-03 16:22:01 24 4
gpt4 key购买 nike

我正在尝试让 Squib 嵌入图像。我有一个 excel 文档 (totm.xlsx),其中包含标题、黄金、描述等字段。在 Excel 文档中,大多数卡片的描述中都有 :A: 或 :M:,我想将它们替换为一个小的 SVG 图标。

以下代码会出现“未识别的本地方法 [embed]”和一连串其他错误:

require 'squib'

Squib::Deck.new(cards: 54) do
background color: :white
data = xlsx file: 'totm.xlsx'

text str: data['Title'], x: 250, y: 55, font: 'Arial 12'
text str: data['Gold'], x: 65, y: 65, font: 'Arial 12'
text(str: data['Description'], x: 65, y: 600, font: 'Arial 12') do [embed]
embed.svg key: ':A:', width: 28, height: 28, file: 'battle-axe.svg'
embed.svg key: ':M:', width: 28, height: 28, file: 'burning-meteor.svg'
end
text str: data['Flavortext'], x: 65, y: 100, font: 'Arial 12'
text str: data['Type'], x: 65, y: 400, font: 'Arial 12'

save_sheet prefix: 'totm_sheet_', margin: 75, gap: 5, trim: 37
end

在嵌入文本的示例中,代码始终使用单个命名字符串 embed_text,但我想调用一个字符串数组。

  embed_text = 'Take 1 :tool: and gain 2 :health:.'
text(str: embed_text, font: 'Sans', font_size: [18, 32, 45],
x: 0, y: 0, width: 180, height: 300, valign: :bottom,
align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
embed.svg key: ':health:', width: 28, height: 28, file: 'glass-heart.svg'
end

最佳答案

[embed] 两边有方括号;如代码示例所示,它应该使用竖线,例如 |embed|

关于ruby - 如何将所有图标嵌入到一个数组中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31925651/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com