Class: RTKIT::Dose
- Inherits:
-
Float
- Object
- Float
- RTKIT::Dose
- Defined in:
- lib/rtkit/dose.rb
Instance Attribute Summary collapse
-
#distribution ⇒ Object
readonly
The DoseDistribution that the single Dose value is derived from.
-
#value ⇒ Object
readonly
The Dose value.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(also: #eql?)
Returns true if the argument is an instance with attributes equal to self.
-
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
-
#initialize(value, distribution) ⇒ Dose
constructor
Creates a new Dose instance.
-
#to_dose ⇒ Object
Returns self.
Constructor Details
#initialize(value, distribution) ⇒ Dose
Creates a new Dose instance.
Parameters
-
value
– Float. A dose value. -
distribution
– The DoseDistribution which this single Dose value belongs to.
31 32 33 34 35 36 |
# File 'lib/rtkit/dose.rb', line 31 def initialize(value, distribution) raise ArgumentError, "Invalid argument 'distribution'. Expected DoseDistribution, got #{distribution.class}." unless distribution.is_a?(DoseDistribution) super(value.to_f) @value = value @distribution = distribution end |
Instance Attribute Details
#distribution ⇒ Object (readonly)
The DoseDistribution that the single Dose value is derived from.
20 21 22 |
# File 'lib/rtkit/dose.rb', line 20 def distribution @distribution end |
#value ⇒ Object (readonly)
The Dose value.
22 23 24 |
# File 'lib/rtkit/dose.rb', line 22 def value @value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
Returns true if the argument is an instance with attributes equal to self.
40 41 42 43 44 |
# File 'lib/rtkit/dose.rb', line 40 def ==(other) if other.respond_to?(:to_dose) other.send(:state) == state end end |
#hash ⇒ Object
Generates a Fixnum hash value for this instance.
50 51 52 |
# File 'lib/rtkit/dose.rb', line 50 def hash state.hash end |
#to_dose ⇒ Object
Returns self.
56 57 58 |
# File 'lib/rtkit/dose.rb', line 56 def to_dose self end |