Class: ThinpXML::UniformDistribution
- Inherits:
-
Distribution
- Object
- Distribution
- ThinpXML::UniformDistribution
- Defined in:
- lib/thinp_xml/distribution.rb
Instance Attribute Summary collapse
-
#start ⇒ Object
Returns the value of attribute start.
-
#stop ⇒ Object
Returns the value of attribute stop.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(start, stop) ⇒ UniformDistribution
constructor
A new instance of UniformDistribution.
Methods inherited from Distribution
Constructor Details
#initialize(start, stop) ⇒ UniformDistribution
Returns a new instance of UniformDistribution.
24 25 26 27 28 29 |
# File 'lib/thinp_xml/distribution.rb', line 24 def initialize(start, stop) raise "invalid range [#{start}..#{stop})" unless start < stop @start = start @stop = stop end |
Instance Attribute Details
#start ⇒ Object
Returns the value of attribute start.
22 23 24 |
# File 'lib/thinp_xml/distribution.rb', line 22 def start @start end |
#stop ⇒ Object
Returns the value of attribute stop.
22 23 24 |
# File 'lib/thinp_xml/distribution.rb', line 22 def stop @stop end |
Instance Method Details
#generate ⇒ Object
31 32 33 |
# File 'lib/thinp_xml/distribution.rb', line 31 def generate @start + rand(@stop - @start) end |