randprize 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +4 -0
- data/lib/randprize/base.rb +28 -0
- data/lib/randprize.rb +7 -0
- data/test/randprize.rb +28 -0
- data/test/test_helper.rb +3 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmZmNDNlYzJhYTdlYzgxNDdjMjQxYjBmYmJjMWI5Y2FkZjk1MGMwOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjBkMWEwOWFmZjlmMTk2MTBiNjM4NDU3NjQ3MTQyOGNmZDhlZmM5Zg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Yjg0MDRhNmU0ZDc3ODFiNzM4ZjU0ZTM4NDFiZGE4ZWU0YjRjNTFkYjhkMTRj
|
10
|
+
Mzc4ZDY4Y2JiZWJjNDFlZGMxMTkxNjJkM2MyYTM5OWRlNjRmZWUzOTAyYjg3
|
11
|
+
YzkwZWEwOWMxMmFiNDA1YTljMGIxZDc2MDIyMzRlZTNlYTc0YzE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmM2YTExNzdmNDM2NTM5MTFjYzYyNzI3NzU5ZWRjM2M0NjlhOGIzNDAzNzQ2
|
14
|
+
MzBmMGM0ZWZiOGUxZDdiZTczN2JiNzE5YWM2ZWMyYTMzNGMzOTcwOWM3YWM3
|
15
|
+
MmYwNzcwNDliMjA2ODVmNTJiOTczZTIyZjM0NjlhMjgxZDgwOWU=
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
module Randprize
|
4
|
+
class Base
|
5
|
+
attr_accessor :randgen, :myrange
|
6
|
+
def debug
|
7
|
+
true
|
8
|
+
end
|
9
|
+
def random_generator
|
10
|
+
self.randgen=Random.new if self.randgen==nil
|
11
|
+
self.randgen
|
12
|
+
end
|
13
|
+
def set_random_generator(r)
|
14
|
+
self.randgen=r
|
15
|
+
end
|
16
|
+
|
17
|
+
def rand
|
18
|
+
self.random_generator.rand
|
19
|
+
end
|
20
|
+
def set_range(range)
|
21
|
+
self.myrange=range
|
22
|
+
end
|
23
|
+
def rand_range
|
24
|
+
self.random_generator.rand(self.myrange)
|
25
|
+
end
|
26
|
+
|
27
|
+
end # Class
|
28
|
+
end #Module
|
data/lib/randprize.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
Dir[File.join(File.dirname(__FILE__), 'randprize/**/*.rb')].sort.each { |lib| require lib }
|
4
|
+
|
5
|
+
module Randprize
|
6
|
+
VERSION = '0.0.1'
|
7
|
+
end
|
data/test/randprize.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class RandprizeTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@f=Randprize::Base.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_basic
|
10
|
+
assert @f.rand!=nil, "should return result"
|
11
|
+
end
|
12
|
+
def test_assign_gen
|
13
|
+
@f.set_random_generator(Random.new)
|
14
|
+
assert @f.random_generator!=Random.new, "diff generatros"
|
15
|
+
end
|
16
|
+
def test_range
|
17
|
+
range=(0..10)
|
18
|
+
@f.set_range(range)
|
19
|
+
1.upto(100) do
|
20
|
+
res=@f.rand_range
|
21
|
+
assert range.include?(res), "range return wrong #{res}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: randprize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Sproule
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Select a random prize from a list with odds
|
14
|
+
email: scott.sproule@ficonab.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/randprize/base.rb
|
20
|
+
- lib/randprize.rb
|
21
|
+
- test/randprize.rb
|
22
|
+
- test/test_helper.rb
|
23
|
+
- README.md
|
24
|
+
homepage: http://github.com/semdinsp/randprize
|
25
|
+
licenses: []
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.4
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project: randprize
|
43
|
+
rubygems_version: 2.0.6
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Base sms application
|
47
|
+
test_files: []
|