Class: RTP::DoseTracking

Inherits:
Record
  • Object
show all
Defined in:
lib/rtp-connect/dose_tracking.rb

Overview

Note:

Relations:

  • Parent: Plan

  • Children: none

The DoseTracking class.

Constant Summary collapse

NR_SURPLUS_ATTRIBUTES =

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

18

Instance Attribute Summary collapse

Attributes inherited from Record

#attributes, #crc, #keyword

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#encode, #get_parent, #load, #to_record, #to_s

Constructor Details

#initialize(parent) ⇒ DoseTracking

Creates a new DoseTracking.

Parameters:

  • parent (Record)

    a record which is used to determine the proper parent of this instance



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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

Instance Attribute Details

#actual_doseObject

Returns the value of attribute actual_dose.



24
25
26
# File 'lib/rtp-connect/dose_tracking.rb', line 24

def actual_dose
  @actual_dose
end

#actual_fractionsObject

Returns the value of attribute actual_fractions.



25
26
27
# File 'lib/rtp-connect/dose_tracking.rb', line 25

def actual_fractions
  @actual_fractions
end

#dose_actionsObject (readonly)

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



17
18
19
# File 'lib/rtp-connect/dose_tracking.rb', line 17

def dose_actions
  @dose_actions
end

#field_idsObject

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



21
22
23
# File 'lib/rtp-connect/dose_tracking.rb', line 21

def field_ids
  @field_ids
end

#parentObject

The Record which this instance belongs to.



15
16
17
# File 'lib/rtp-connect/dose_tracking.rb', line 15

def parent
  @parent
end

#region_coeffsObject

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



23
24
25
# File 'lib/rtp-connect/dose_tracking.rb', line 23

def region_coeffs
  @region_coeffs
end

#region_nameObject

Returns the value of attribute region_name.



18
19
20
# File 'lib/rtp-connect/dose_tracking.rb', line 18

def region_name
  @region_name
end

#region_prior_doseObject

Returns the value of attribute region_prior_dose.



19
20
21
# File 'lib/rtp-connect/dose_tracking.rb', line 19

def region_prior_dose
  @region_prior_dose
end

Class Method Details

.load(string, parent) ⇒ DoseTracking

Creates a new DoseTracking by parsing a RTPConnect string line.

Parameters:

  • string (#to_s)

    the dose tracking definition record string line

  • parent (Record)

    a record which is used to determine the proper parent of this instance

Returns:

Raises:

  • (ArgumentError)

    if given a string containing an invalid number of elements



34
35
36
37
# File 'lib/rtp-connect/dose_tracking.rb', line 34

def self.load(string, parent)
  d = self.new(parent)
  d.load(string)
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Checks for equality.

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

Parameters:

  • other

    an object to be compared with self.

Returns:

  • (Boolean)

    true if self and other are considered equivalent



73
74
75
76
77
# File 'lib/rtp-connect/dose_tracking.rb', line 73

def ==(other)
  if other.respond_to?(:to_dose_tracking)
    other.send(:state) == state
  end
end

#childrenArray

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.

Returns:

  • (Array)

    an emtpy array



86
87
88
89
# File 'lib/rtp-connect/dose_tracking.rb', line 86

def children
  #return @dose_actions
  return Array.new
end

#hashFixnum

Note:

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

Computes a hash code for this object.

Returns:

  • (Fixnum)

    the object’s hash code



97
98
99
# File 'lib/rtp-connect/dose_tracking.rb', line 97

def hash
  state.hash
end

#to_dose_trackingDoseTracking

Returns self.

Returns:



122
123
124
# File 'lib/rtp-connect/dose_tracking.rb', line 122

def to_dose_tracking
  self
end

#valuesArray<String> Also known as: state

Note:

The CRC is not considered part of the actual values and is excluded.

Collects the values (attributes) of this instance.

Returns:

  • (Array<String>)

    an array of attributes (in the same order as they appear in the RTP string)



106
107
108
109
110
111
112
113
114
115
116
# 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