Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adds methods for iterating over hiragana rows/columns

  • Loading branch information...
commit d075237567703188f623edc3e2f4ef14314e8251 1 parent 7d9b633
@Najaf Najaf authored
View
2  .rspec
@@ -0,0 +1,2 @@
+--color
+--format documentation
View
5 kana-grid.gemspec
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
spec.version = Kana::Grid::VERSION
spec.authors = ["Najaf Ali"]
spec.email = ["ali@happybearsoftware.com"]
- spec.description = %q{TODO: Write a gem description}
- spec.summary = %q{TODO: Write a gem summary}
+ spec.description = %q{Write a gem description}
+ spec.summary = %q{Write a gem summary}
spec.homepage = ""
spec.license = "MIT"
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
+ spec.add_development_dependency "rspec"
end
View
3  lib/kana-grid.rb
@@ -0,0 +1,3 @@
+$: << File.dirname(__FILE__)
+
+autoload :Hiragana, 'kana-grid/hiragana'
View
28 lib/kana-grid/hiragana.rb
@@ -0,0 +1,28 @@
+class Hiragana
+ class << self
+ def columns(opts = { align: false })
+ align = opts[:align]
+ [ %w(あ い う え お),
+ %w(か き く け こ),
+ %w(さ し す せ そ),
+ %w(た ち つ て と),
+ %w(な に ぬ ね の),
+ %w(は ひ ふ へ ほ),
+ %w(ま み む め も),
+ align ? ['', '', '', '', ''] : %w(や ゆ よ),
+ %w(ら り る れ ろ),
+ align ? ['', '', '', '', ''] : %w(わ を),
+ align ? ['', '', '', '', ''] : %w()
+ ]
+ end
+
+ def rows
+ @rows ||= [ ['', '', '', '', '', '', '', '', '', '', ''],
+ ['', '', '', '', '', '', '', '', '', '', '' ],
+ ['', '', '', '', '', '', '', '', '', '', '' ],
+ ['', '', '', '', '', '', '', '', '', '', '' ],
+ ['', '', '', '', '', '', '', '', '', '', '' ]
+ ]
+ end
+ end
+end
View
47 spec/hiragana_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe Hiragana do
+ describe '.columns' do
+ it 'returns all hiragana columns' do
+ Hiragana.columns.should == [ %w(あ い う え お),
+ %w(か き く け こ),
+ %w(さ し す せ そ),
+ %w(た ち つ て と),
+ %w(な に ぬ ね の),
+ %w(は ひ ふ へ ほ),
+ %w(ま み む め も),
+ %w(や ゆ よ),
+ %w(ら り る れ ろ),
+ %w(わ を),
+ %w() ]
+ end
+
+ it 'adds empty space for alignment if align: true' do
+ Hiragana.columns(align: true).should == [ %w(あ い う え お),
+ %w(か き く け こ),
+ %w(さ し す せ そ),
+ %w(た ち つ て と),
+ %w(な に ぬ ね の),
+ %w(は ひ ふ へ ほ),
+ %w(ま み む め も),
+ ['', '', '', '', ''],
+ %w(ら り る れ ろ),
+ ['', '', '', '', ''],
+ ['', '', '', '', '']
+ ]
+ end
+ end
+
+ describe '.rows' do
+ it 'returns all hiragana rows with alignment' do
+ rows = [ ['', '', '', '', '', '', '', '', '', '', ''],
+ ['', '', '', '', '', '', '', '', '', '', '' ],
+ ['', '', '', '', '', '', '', '', '', '', '' ],
+ ['', '', '', '', '', '', '', '', '', '', '' ],
+ ['', '', '', '', '', '', '', '', '', '', '' ]
+ ]
+
+ Hiragana.rows.should == rows
+ end
+ end
+end
View
1  spec/spec_helper.rb
@@ -0,0 +1 @@
+require './lib/kana-grid'
Please sign in to comment.
Something went wrong with that request. Please try again.