kidomath 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'kidomath'
3
+ puts Kidomath.start
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cadbury'
3
+ class Kidomath
4
+
5
+ def self.level
6
+ print <<'HEREDOC'
7
+ Welcome to kido math!.red
8
+ At which level are you in?
9
+ 1. Learner.
10
+ 2. Intermediate.
11
+ 3. Expert.
12
+
13
+ Please Enter your level :
14
+ HEREDOC
15
+ self.parseopt()
16
+ end
17
+
18
+ def self.parseopt
19
+ choice = gets.chomp.to_i
20
+ if (1..3) === choice
21
+ choice
22
+ else
23
+ self.level()
24
+ end
25
+ end
26
+
27
+ def self.ask(level=1)
28
+ operations = ['+','-','*','/']
29
+ case level
30
+ when 1
31
+ rand1 = 1 + rand(10)
32
+ rand2 = 1 + rand(10)
33
+ randop = operations[rand(operations.length)].chomp
34
+ if rand1 > rand2
35
+ res = rand1.send(randop,rand2)
36
+ print "#{rand1} #{randop} #{rand2} = "
37
+ else
38
+ res = rand2.send(randop,rand1)
39
+ print "#{rand2} #{randop} #{rand1} = "
40
+ end
41
+ kid_said = gets.to_i
42
+ if res == kid_said
43
+ print "Correct answer, here are the gems for you :) keep it up! "
44
+ Cadbury.gems(res)
45
+ print "\n"
46
+ else
47
+ puts "Sorry the anwser is #{res} :("
48
+ end
49
+ when 2
50
+ rand1 = 1 + rand(100)
51
+ rand2 = 1 + rand(100)
52
+ randop = operations[rand(operations.length)].chomp
53
+ res = rand1.send(randop,rand2)
54
+ print "#{rand1} #{randop} #{rand2} = "
55
+ kid_said = gets.to_i
56
+ if res == kid_said
57
+ print "Correct answer, here are the gems for you :) keep it up! "
58
+ Cadbury.gems(10)
59
+ print "\n"
60
+ else
61
+ puts "Sorry the anwser is #{res} :("
62
+ end
63
+ when 3
64
+ rand1 = 1 + rand(200)
65
+ rand2 = 1 + rand(200)
66
+ randop = operations[rand(operations.length)].chomp
67
+ res = rand1.send(randop,rand2)
68
+ print "#{rand1} #{randop} #{rand2} = "
69
+ kid_said = gets.to_i
70
+ if res == kid_said
71
+ print "Correct answer, here are the gems for you :) keep it up! "
72
+ Cadbury.gems(10)
73
+ print "\n"
74
+ else
75
+ puts "Sorry the anwser is #{res} :("
76
+ end
77
+ end
78
+ end
79
+
80
+ def self.start
81
+ level = self.level()
82
+ self.ask(level)
83
+ print "Want to play more? Type 'Yes or No' : "
84
+ more = gets
85
+ if more.chomp.casecmp("Yes") == 0
86
+ self.start()
87
+ else
88
+ puts "Bye!!! :o)"
89
+ exit
90
+ end
91
+
92
+ end
93
+ end
94
+
95
+ Kidomath.start
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+ require 'xkcd'
3
+
4
+ class GitaTest < Test::Unit::TestCase
5
+ def test_GET_get
6
+ assert_not_nil Gita.get
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kidomath
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hemanth.HM
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cadbury
16
+ requirement: &85466390 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *85466390
25
+ description: ! '"Kids do math on the CLI"'
26
+ email: hemanth.hm@gmail.com
27
+ executables:
28
+ - kidomath
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - Rakefile
33
+ - lib/kidomath.rb
34
+ - bin/kidomath
35
+ - test/test_gita.rb
36
+ homepage: http://rubygems.org/gems/kidomath
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 1.8.10
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: XCKD random img urls!
60
+ test_files:
61
+ - test/test_gita.rb
62
+ has_rdoc: