{"action":"created","issue":{"url":"https://api.github.com/repos/andymeneely/squib/issues/143","repository_url":"https://api.github.com/repos/andymeneely/squib","labels_url":"https://api.github.com/repos/andymeneely/squib/issues/143/labels{/name}","comments_url":"https://api.github.com/repos/andymeneely/squib/issues/143/comments","events_url":"https://api.github.com/repos/andymeneely/squib/issues/143/events","html_url":"https://github.com/andymeneely/squib/issues/143","id":141953836,"number":143,"title":"Error when using Embed with XLSX data","user":{"login":"CovertDad","id":573332,"avatar_url":"https://avatars.githubusercontent.com/u/573332?v=3","gravatar_id":"","url":"https://api.github.com/users/CovertDad","html_url":"https://github.com/CovertDad","followers_url":"https://api.github.com/users/CovertDad/followers","following_url":"https://api.github.com/users/CovertDad/following{/other_user}","gists_url":"https://api.github.com/users/CovertDad/gists{/gist_id}","starred_url":"https://api.github.com/users/CovertDad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CovertDad/subscriptions","organizations_url":"https://api.github.com/users/CovertDad/orgs","repos_url":"https://api.github.com/users/CovertDad/repos","events_url":"https://api.github.com/users/CovertDad/events{/privacy}","received_events_url":"https://api.github.com/users/CovertDad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-18T19:10:59Z","updated_at":"2016-03-18T20:11:15Z","closed_at":null,"body":"If I try to use the embed command with a fixed amount of cards, everything works fine.  If I try to use a linked XLSX file for my data, it blows up.\r\n\r\nI copied a bit from the sample to make sure it wasn't something else I was doing wrong.\r\n\r\nThis works:\r\n\r\n```ruby\r\nrequire 'squib'\r\nSquib::Deck.new(cards: 3) do\r\n  str = 'Take 1 :tool: and gain 2 :health:.'\r\n  text(str: str, font: 'Sans', font_size: [18, 26, 35],\r\n       x: 0, y: 0, width: 180, height: 300, valign: :bottom,\r\n       align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|\r\n    embed.svg key: ':tool:',   width: [28, 42, 56], height: [28, 42, 56], file: 'images/cubes-blue.svg'\r\n    embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'images/cubes-red.svg'\r\n  end\r\n  save_sheet prefix: 'embed_multisheet_', columns: 3\r\nend\r\n```\r\n\r\nThis produces an error:\r\n```ruby\r\nrequire 'squib'\r\n\r\ndata = Squib.xlsx file:'Cards.xlsx'\r\nnum_cards = data['Name'].size    \r\n\r\nSquib::Deck.new(cards: num_cards) do\r\n  str = 'Take 1 :tool: and gain 2 :health:.'\r\n  text(str: str, font: 'Sans', font_size: [18, 26, 35],\r\n       x: 0, y: 0, width: 180, height: 300, valign: :bottom,\r\n       align: :left, ellipsize: false, justify: false, hint: :cyan) do |embed|\r\n    embed.svg key: ':tool:',   width: [28, 42, 56], height: [28, 42, 56], file: 'images/cubes-blue.svg'\r\n    embed.svg key: ':health:', width: [28, 42, 56], height: [28, 42, 56], file: 'images/cubes-red.svg'\r\n  end\r\n  save_sheet prefix: 'embed_multisheet_', columns: 3\r\nend\r\n```\r\n\r\nSpecifically, the error is:\r\n```\r\n/Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/graphics/text.rb:88:in `process_embeds': undefined method `*' for nil:NilClass (NoMethodError)\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/graphics/text.rb:149:in `block in text'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/card.rb:50:in `yield'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/card.rb:50:in `use_cairo'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/graphics/text.rb:124:in `text'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/api/text.rb:60:in `block in text'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/args/card_range.rb:13:in `call'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/args/card_range.rb:13:in `block in each'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/args/card_range.rb:13:in `each'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/args/card_range.rb:13:in `each'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/api/text.rb:60:in `text'\r\n\tfrom deck.rb:29:in `block in <main>'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/deck.rb:73:in `instance_eval'\r\n\tfrom /Library/Ruby/Gems/2.0.0/gems/squib-0.9.0/lib/squib/deck.rb:73:in `initialize'\r\n\tfrom deck.rb:27:in `new'\r\n\tfrom deck.rb:27:in `<main>'\r\n```"},"comment":{"url":"https://api.github.com/repos/andymeneely/squib/issues/comments/198521677","html_url":"https://github.com/andymeneely/squib/issues/143#issuecomment-198521677","issue_url":"https://api.github.com/repos/andymeneely/squib/issues/143","id":198521677,"user":{"login":"andymeneely","id":341847,"avatar_url":"https://avatars.githubusercontent.com/u/341847?v=3","gravatar_id":"","url":"https://api.github.com/users/andymeneely","html_url":"https://github.com/andymeneely","followers_url":"https://api.github.com/users/andymeneely/followers","following_url":"https://api.github.com/users/andymeneely/following{/other_user}","gists_url":"https://api.github.com/users/andymeneely/gists{/gist_id}","starred_url":"https://api.github.com/users/andymeneely/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andymeneely/subscriptions","organizations_url":"https://api.github.com/users/andymeneely/orgs","repos_url":"https://api.github.com/users/andymeneely/repos","events_url":"https://api.github.com/users/andymeneely/events{/privacy}","received_events_url":"https://api.github.com/users/andymeneely/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T20:11:15Z","updated_at":"2016-03-18T20:11:15Z","body":"Oh I think I know what's going on. num_cards is much bigger than 3, right? That would mean that `nil` is getting passed to width and height. Because this:\r\n\r\n```\r\n$ irb\r\nirb(main):001:0> arr = [1,2,3]\r\n=> [1, 2, 3]\r\nirb(main):002:0> arr[56]\r\n=> nil\r\n```\r\n\r\nAnd Squib doesn't like that. To be fair, Squib should tell you up front that it doesn't like `width: nil` instead of failing deep within its logic. "}}