如何在阵列中嵌入所有图标?

时间:2015-08-10 17:28:00

标签: ruby squib

我想让Squib嵌入图像。我有一个excel doc(totm.xlsx),其中包含Title,Gold,Description等字段。在Excel文档中,大多数卡片都有:A:或:M:在描述中我想替换那些一个小的SVG图标。

以下代码咳嗽了“身份不明的本地方法[嵌入]'还有一连串的其他错误:

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

1 个答案:

答案 0 :(得分:1)

[embed]附近有括号;如代码示例所示,它应该使用垂直条,例如|embed|