Browse Source

Range option shouldn't fail on []

Fixes #107
dev
Andy Meneely 10 years ago
parent
commit
e8d7480a63
  1. 3
      CHANGELOG.md
  2. 2
      lib/squib/args/card_range.rb
  3. 5
      spec/args/range_spec.rb

3
CHANGELOG.md

@ -9,6 +9,9 @@ Features
Compatibility change:
* Stripping leading and trailing whitespace of xlsx and csv values by default might change how your data gets parsed.
Bugs fixes:
* The `range` option everywhere doesn't fail on `[]` (#107)
## v0.7.0 / 2015-09-11
Features

2
lib/squib/args/card_range.rb

@ -23,7 +23,7 @@ module Squib
input = 0..(deck_size - 1) if input == :all
input = (input.to_i)..(input.to_i) if input.respond_to? :to_i
raise ArgumentError.new("#{input} must be Enumerable (i.e. respond_to :each).") unless input.respond_to? :each
raise ArgumentError.new("#{input} is outside of deck range of 0..#{deck_size-1}") if input.max > (deck_size - 1)
raise ArgumentError.new("#{input} is outside of deck range of 0..#{deck_size-1}") if (!input.max.nil?) && (input.max > (deck_size - 1))
input
end

5
spec/args/range_spec.rb

@ -33,4 +33,9 @@ describe Squib::Args::CardRange do
expect(range.to_a).to eq([0])
end
it 'allows [] as an empty range' do
range = Squib::Args::CardRange.new([], deck_size: 5)
expect(range.to_a).to eq([])
end
end
Loading…
Cancel
Save