Class: RTKIT::Dose

Inherits:
Float
  • Object
show all
Defined in:
lib/rtkit/dose.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Raises:

  • (ArgumentError)


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

#distributionObject (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

#valueObject (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

#hashObject

Generates a Fixnum hash value for this instance.



50
51
52
# File 'lib/rtkit/dose.rb', line 50

def hash
  state.hash
end

#to_doseObject

Returns self.



56
57
58
# File 'lib/rtkit/dose.rb', line 56

def to_dose
  self
end