wordgrid 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/wordgrid.rb +6 -1
  2. data/spec/wordgrid_spec.rb +21 -0
  3. metadata +3 -3
data/lib/wordgrid.rb CHANGED
@@ -45,6 +45,11 @@ grid takes a Matrix object and validates that it is acceptable.
45
45
  end
46
46
 
47
47
  @grid = new_grid
48
+
49
+ # lowercase each cell in the grid.
50
+ @grid.each do |cell|
51
+ cell.downcase!
52
+ end
48
53
  end
49
54
 
50
55
  =begin
@@ -66,7 +71,7 @@ not find "BEADED":
66
71
  - Nothing
67
72
  =end
68
73
  def has_word?(word)
69
- @letters = word.split('')
74
+ @letters = word.downcase.split('')
70
75
  first_cells = @grid.find_cells_for_letter(@letters[0])
71
76
 
72
77
  @cell_stack = []
@@ -66,6 +66,22 @@ describe Wordgrid, "#grid" do
66
66
  expect { wordgrid = Wordgrid.new(grid) }.to raise_error
67
67
  end
68
68
 
69
+ it "lowercases all the letters in the grid" do
70
+ grid = Matrix[
71
+ [ "A", "b", "c" ],
72
+ [ "d", "E", "f" ],
73
+ [ "g", "h", "I" ]
74
+ ]
75
+
76
+ lc_grid = Matrix[
77
+ [ "a", "b", "c" ],
78
+ [ "d", "e", "f" ],
79
+ [ "g", "h", "i" ]
80
+ ]
81
+
82
+ wordgrid = Wordgrid.new(grid)
83
+ wordgrid.grid.should eq(lc_grid)
84
+ end
69
85
  end
70
86
 
71
87
  describe Wordgrid, "#find_word" do
@@ -93,4 +109,9 @@ describe Wordgrid, "#find_word" do
93
109
  wordgrid = Wordgrid.new(grid)
94
110
  wordgrid.has_word?("beady").should eq(false)
95
111
  end
112
+
113
+ it "should find the word regardless of case" do
114
+ wordgrid = Wordgrid.new(grid)
115
+ wordgrid.has_word?("BeAd").should eq(true)
116
+ end
96
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordgrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-14 00:00:00.000000000 Z
12
+ date: 2012-04-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Visualizing and solving games like boggle, scramble with friends, etc
15
15
  email: jonathansen@gmail.com
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 1.8.22
42
+ rubygems_version: 1.8.21
43
43
  signing_key:
44
44
  specification_version: 3
45
45
  summary: Wordgrid