dice_roll 0.0.1
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.
- data/lib/dice.rb +32 -0
- metadata +57 -0
data/lib/dice.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Dice
|
2
|
+
|
3
|
+
class Roller
|
4
|
+
|
5
|
+
attr_accessor :result, :total
|
6
|
+
|
7
|
+
def initialize(no_of_dice=1,sides=6)
|
8
|
+
@no_of_dice = no_of_dice
|
9
|
+
@sides = sides
|
10
|
+
@result = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def result
|
14
|
+
@result
|
15
|
+
end
|
16
|
+
|
17
|
+
def throw
|
18
|
+
@result.clear
|
19
|
+
@no_of_dice.times do |die|
|
20
|
+
@result << rand(@sides) + 1
|
21
|
+
end
|
22
|
+
@result
|
23
|
+
end
|
24
|
+
|
25
|
+
def total
|
26
|
+
@result.inject(:+)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dice_roll
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stuart Hanscombe
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-19 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: A library that throws some dice and gives you the result
|
18
|
+
email:
|
19
|
+
- hanscs1969@yahoo.co.uk
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- lib/dice.rb
|
28
|
+
has_rdoc: true
|
29
|
+
homepage:
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: "0"
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.5.3
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Simple dice throwing code
|
56
|
+
test_files: []
|
57
|
+
|