Jldrill Git C0 Coverage Information - RCov

lib/jldrill/model/moji/Kana.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/jldrill/model/moji/Kana.rb 123 102
97.56%
97.06%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 require 'jldrill/model/DataFile'
2 
3 module JLDrill
4     # Represents a japanese phonetic character (either hiragana or
5     # katakana).
6 	class Kana
7 	
8 	    STROKES_RE = /^S(\d+)/
9 	
10 		attr_reader :character, :romaji, :pronunciation, 
11                     :strokes, :examples
12 	
13 		def initialize(character, romaji, pronunciation, strokes, examples)
14 			@character = character
15 			@romaji = romaji
16 			@pronunciation = pronunciation
17 			@strokes = strokes
18 			@examples = examples
19 		end
20 
21         def Kana.getParts(string, separator)
22             retVal = nil
23             if !string.nil?
24                 retVal = string.split(separator, -1)
25             end
26             retVal
27         end
28         
29         def Kana.validSections?(sections)
30             !sections.nil? && sections.size == 6 && !sections[0].nil?
31         end
32 		
33 		def Kana.parse(string)
34 			entry = nil
35 			sections = Kana.getParts(string.chomp, "|")
36 			return if !Kana.validSections?(sections)
37 			character = sections[0]
38 			romaji = Kana.getParts(sections[2], "/")
39 			examples = Kana.getParts(sections[5], ",")
40             pronunciation = sections[3]
41 			commands = Kana.getParts(sections[1], " ")
42 			strokes = nil
43 			commands.each do |command|
44 			    case command
45 			        when STROKES_RE
46         				strokes = $1.to_i(10)
47 			    end
48 			end
49 			Kana.new(character, romaji, pronunciation, strokes, examples)
50 		end
51 
52         def eql?(kana)
53             @character.eql?(kana.character) &&
54                 @romaji.eql?(kana.romaji) &&
55                 @pronunciation.eql?(kana.pronunciation) &&
56                 @strokes.eql?(kana.strokes) &&
57                 @examples.eql?(kana.examples)
58         end
59 		
60 		def to_s
61 		    retVal = @character
62 		    retVal += " [" + @romaji.join(" ") + "]\n"
63             retVal += @pronunciation + "\n\n"
64 		    retVal += "Strokes: #{@strokes}\n\n"
65             retVal += "English Examples: " + @examples.join(", ") + "\n"
66 		    retVal
67 		end
68 	end
69 
70 	class KanaList < Array
71 	
72 		def KanaList.fromString(string)
73 			list = KanaList.new
74 			string.each_line do |line|
75 				list.parse(line)
76 			end
77 			list
78 		end
79 		
80 		def KanaList.fromFile(filename)
81 			list = KanaList.new
82 			IO.foreach(filename) do |line|
83 				list.parse(line)			
84 			end
85 			list
86 		end
87 		
88 		def parse(string)
89 			entry = Kana.parse(string)
90 			if(!entry.nil?)
91 				self.push(entry)
92 			end
93 		end
94 		
95 		def findChar(char)
96 		    self.find do |entry|
97 		        entry.character == char
98 		    end
99 		end
100 
101 		def to_s
102 			self.join("\n")
103 		end
104 	end
105 
106     class KanaFile < DataFile
107         attr_reader :kanaList
108         attr_writer :kanaList
109 
110         def initialize
111             super
112             @kanaList = KanaList.new
113         end
114 
115         def dataSize
116             @kanaList.size
117         end
118 
119         def parser
120             @kanaList
121         end
122     end
123 end

Generated on Mon May 23 16:17:46 +0900 2011 with rcov 0.9.8