class RTP::DoseTracking

The DoseTracking class.

@note Relations:

* Parent: Plan
* Children: none

Constants

NR_SURPLUS_ATTRIBUTES

The number of attributes not having their own variable for this record (20 - 2).

Attributes

actual_dose[R]
actual_fractions[R]
dose_actions[R]

The DoseAction records (if any) that belongs to this DoseTracking.

field_ids[R]

Note: This attribute contains an array of all field_id values (1..10).

parent[RW]

The Record which this instance belongs to.

region_coeffs[R]

Note: This attribute contains an array of all reg_coeff values (1..10).

region_name[R]
region_prior_dose[R]

Public Class Methods

load(string, parent) click to toggle source

Creates a new DoseTracking by parsing a RTPConnect string line.

@param [#to_s] string the dose tracking definition record string line @param [Record] parent a record which is used to determine the proper parent of this instance @return [DoseTracking] the created DoseTracking instance @raise [ArgumentError] if given a string containing an invalid number of elements

# File lib/rtp-connect/dose_tracking.rb, line 34
def self.load(string, parent)
  d = self.new(parent)
  d.load(string)
end
new(parent) click to toggle source

Creates a new DoseTracking.

@param [Record] parent a record which is used to determine the proper parent of this instance

Calls superclass method
# File lib/rtp-connect/dose_tracking.rb, line 43
def initialize(parent)
  super('DOSE_DEF', 24, 26)
  # Child records:
  @dose_actions = Array.new
  # Parent relation (may get more than one type of record here):
  @parent = get_parent(parent.to_record, Plan)
  @parent.add_dose_tracking(self)
  @field_ids = Array.new(10)
  @region_coeffs = Array.new(10)
  @attributes = [
    # Required:
    :keyword,
    :region_name,
    :region_prior_dose,
    :field_ids,
    :region_coeffs,
    # Optional:
    :actual_dose,
    :actual_fractions
  ]
end

Public Instance Methods

==(other) click to toggle source

Checks for equality.

Other and self are considered equivalent if they are of compatible types and their attributes are equivalent.

@param other an object to be compared with self. @return [Boolean] true if self and other are considered equivalent

# File lib/rtp-connect/dose_tracking.rb, line 73
def ==(other)
  if other.respond_to?(:to_dose_tracking)
    other.send(:state) == state
  end
end
Also aliased as: eql?
actual_dose=(value) click to toggle source

Sets the actual_dose attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/dose_tracking.rb, line 166
def actual_dose=(value)
  @actual_dose = value && value.to_s
end
actual_fractions=(value) click to toggle source

Sets the actual_fractions attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/dose_tracking.rb, line 174
def actual_fractions=(value)
  @actual_fractions = value && value.to_s
end
children() click to toggle source

As of now, gives an empty array. However, by definition, this record may have dose action (point) records as children, but this is not implemented yet.

@return [Array] an emtpy array

# File lib/rtp-connect/dose_tracking.rb, line 86
def children
  #return @dose_actions
  return Array.new
end
eql?(other)
Alias for: ==
field_ids=(array) click to toggle source

Sets the field_ids attribute.

@note As opposed to the ordinary (string) attributes, this attribute

contains an array holding all 10 Field ID string values.

@param [Array<nil, to_s>] array the new attribute values

# File lib/rtp-connect/dose_tracking.rb, line 132
def field_ids=(array)
  @field_ids = array.to_a.validate_and_process(10)
end
hash() click to toggle source

Computes a hash code for this object.

@note Two objects with the same attributes will have the same hash code.

@return [Fixnum] the object's hash code

# File lib/rtp-connect/dose_tracking.rb, line 97
def hash
  state.hash
end
region_coeffs=(array) click to toggle source

Sets the region_coeffs attribute.

@note As opposed to the ordinary (string) attributes, this attribute

contains an array holding all 10 Region Coeff string values.

@param [Array<nil, to_s>] array the new attribute values

# File lib/rtp-connect/dose_tracking.rb, line 142
def region_coeffs=(array)
  @region_coeffs = array.to_a.validate_and_process(10)
end
region_name=(value) click to toggle source

Sets the region_name attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/dose_tracking.rb, line 150
def region_name=(value)
  @region_name = value && value.to_s
end
region_prior_dose=(value) click to toggle source

Sets the region_prior_dose attribute.

@param [nil, to_s] value the new attribute value

# File lib/rtp-connect/dose_tracking.rb, line 158
def region_prior_dose=(value)
  @region_prior_dose = value && value.to_s
end
to_dose_tracking() click to toggle source

Returns self.

@return [DoseTracking] self

# File lib/rtp-connect/dose_tracking.rb, line 122
def to_dose_tracking
  self
end
values() click to toggle source

Collects the values (attributes) of this instance.

@note The CRC is not considered part of the actual values and is excluded. @return [Array<String>] an array of attributes (in the same order as they appear in the RTP string)

# File lib/rtp-connect/dose_tracking.rb, line 106
def values
  [
    @keyword,
    @region_name,
    @region_prior_dose,
    # Need to join every other two elements from these two arrays together:
    *@field_ids.zip(@region_coeffs).flatten,
    @actual_dose,
    @actual_fractions
  ]
end
Also aliased as: state

Private Instance Methods

import_indices(length) click to toggle source

Gives an array of indices indicating where the attributes of this record gets its values from in the comma separated string which the instance is created from.

@param [Integer] length the number of elements to create in the indices array

# File lib/rtp-connect/dose_tracking.rb, line 194
def import_indices(length)
  # Note that this method is defined in the parent Record class, where it is
  # used for most record types. However, because this record has two attributes
  # which contain an array of values, we use a custom import_indices method.
  ind = Array.new(length - NR_SURPLUS_ATTRIBUTES) { |i| i }
  # Override indices for field_ids and region_coeffs:
  ind[3] = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
  ind[4] = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
  ind[5, 6] = [23, 24]
  ind
end
state()

Collects the attributes of this instance.

@note The CRC is not considered part of the attributes of interest and is excluded @return [Array<String>] an array of attributes

Alias for: values