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.

Instance Attribute Summary collapse

Attributes inherited from Record

#crc, #keyword

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#encode, #get_parent, #load, #to_record

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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rtp-connect/dose_tracking.rb', line 40

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.



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

def actual_dose
  @actual_dose
end

#actual_fractionsObject

Returns the value of attribute actual_fractions.



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

def actual_fractions
  @actual_fractions
end

#dose_actionsObject (readonly)

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



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

def dose_actions
  @dose_actions
end

#field_idsObject

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



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

def field_ids
  @field_ids
end

#parentObject (readonly)

The Record which this instance belongs to.



12
13
14
# File 'lib/rtp-connect/dose_tracking.rb', line 12

def parent
  @parent
end

#region_coeffsObject

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



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

def region_coeffs
  @region_coeffs
end

#region_nameObject

Returns the value of attribute region_name.



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

def region_name
  @region_name
end

#region_prior_doseObject

Returns the value of attribute region_prior_dose.



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

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



31
32
33
34
# File 'lib/rtp-connect/dose_tracking.rb', line 31

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



70
71
72
73
74
# File 'lib/rtp-connect/dose_tracking.rb', line 70

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



83
84
85
86
# File 'lib/rtp-connect/dose_tracking.rb', line 83

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



94
95
96
# File 'lib/rtp-connect/dose_tracking.rb', line 94

def hash
  state.hash
end

#to_dose_trackingDoseTracking

Returns self.

Returns:



119
120
121
# File 'lib/rtp-connect/dose_tracking.rb', line 119

def to_dose_tracking
  self
end

#to_sString Also known as: to_str

Encodes the DoseTracking object + any hiearchy of child objects, to a properly formatted RTPConnect ascii string.

Returns:

  • (String)

    an RTP string with a single or multiple lines/records



128
129
130
131
132
133
134
135
136
# File 'lib/rtp-connect/dose_tracking.rb', line 128

def to_s
  str = encode
  if children
    children.each do |child|
      str += child.to_s
    end
  end
  return str
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)



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/rtp-connect/dose_tracking.rb', line 103

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