Class: RTP::Prescription
- Defined in:
- lib/rtp-connect/prescription.rb
Overview
Relations:
-
Parent: Plan
-
Children: SiteSetup, SimulationField, Field
The Prescription site class.
Constant Summary
Constants inherited from Record
Instance Attribute Summary collapse
-
#course_id ⇒ Object
Returns the value of attribute course_id.
-
#dose_spec ⇒ Object
Returns the value of attribute dose_spec.
-
#dose_ttl ⇒ Object
Returns the value of attribute dose_ttl.
-
#dose_tx ⇒ Object
Returns the value of attribute dose_tx.
-
#fields ⇒ Object
readonly
An array of Field records (if any) that belongs to this Prescription.
-
#modality ⇒ Object
Returns the value of attribute modality.
-
#number_of_fields ⇒ Object
Returns the value of attribute number_of_fields.
-
#parent ⇒ Object
The Record which this instance belongs to.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#rx_depth ⇒ Object
Returns the value of attribute rx_depth.
-
#rx_note ⇒ Object
Returns the value of attribute rx_note.
-
#rx_site_name ⇒ Object
Returns the value of attribute rx_site_name.
-
#simulation_fields ⇒ Object
readonly
An array of SimulationField records (if any) that belongs to this Prescription.
-
#site_setup ⇒ Object
readonly
The SiteSetup record (if any) that belongs to this Prescription.
-
#technique ⇒ Object
Returns the value of attribute technique.
Attributes inherited from Record
Class Method Summary collapse
-
.load(string, parent) ⇒ Prescription
Creates a new Prescription site by parsing a RTPConnect string line.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks for equality.
-
#add_field(child) ⇒ Object
Adds a treatment field record to this instance.
-
#add_simulation_field(child) ⇒ Object
Adds a simulation field record to this instance.
-
#add_site_setup(child) ⇒ Object
Adds a site setup record to this instance.
-
#children ⇒ Array<SiteSetup, SimulationField, Field>
Collects the child records of this instance in a properly sorted array.
-
#delete(record) ⇒ Object
Removes the reference of the given instance from this instance.
-
#delete_fields ⇒ Object
Removes all field references from this instance.
-
#delete_simulation_fields ⇒ Object
Removes all simulation_field references from this instance.
-
#delete_site_setup ⇒ Object
Removes the site setup reference from this instance.
-
#hash ⇒ Fixnum
Computes a hash code for this object.
-
#initialize(parent) ⇒ Prescription
constructor
Creates a new Prescription site.
-
#to_prescription ⇒ Prescription
Returns self.
Methods inherited from Record
#encode, #get_parent, #load, #to_record, #to_s, #values
Constructor Details
#initialize(parent) ⇒ Prescription
Creates a new Prescription site.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rtp-connect/prescription.rb', line 47 def initialize(parent) super('RX_DEF', 4, 13) # Child objects: @site_setup = nil @fields = Array.new @simulation_fields = Array.new # Parent relation (may get more than one type of record here): @parent = get_parent(parent.to_record, Plan) @parent.add_prescription(self) @attributes = [ # Required: :keyword, :course_id, :rx_site_name, # Optional: :technique, :modality, :dose_spec, :rx_depth, :dose_ttl, :dose_tx, :pattern, :rx_note, :number_of_fields ] end |
Instance Attribute Details
#course_id ⇒ Object
Returns the value of attribute course_id.
19 20 21 |
# File 'lib/rtp-connect/prescription.rb', line 19 def course_id @course_id end |
#dose_spec ⇒ Object
Returns the value of attribute dose_spec.
23 24 25 |
# File 'lib/rtp-connect/prescription.rb', line 23 def dose_spec @dose_spec end |
#dose_ttl ⇒ Object
Returns the value of attribute dose_ttl.
25 26 27 |
# File 'lib/rtp-connect/prescription.rb', line 25 def dose_ttl @dose_ttl end |
#dose_tx ⇒ Object
Returns the value of attribute dose_tx.
26 27 28 |
# File 'lib/rtp-connect/prescription.rb', line 26 def dose_tx @dose_tx end |
#fields ⇒ Object (readonly)
An array of Field records (if any) that belongs to this Prescription.
18 19 20 |
# File 'lib/rtp-connect/prescription.rb', line 18 def fields @fields end |
#modality ⇒ Object
Returns the value of attribute modality.
22 23 24 |
# File 'lib/rtp-connect/prescription.rb', line 22 def modality @modality end |
#number_of_fields ⇒ Object
Returns the value of attribute number_of_fields.
29 30 31 |
# File 'lib/rtp-connect/prescription.rb', line 29 def number_of_fields @number_of_fields end |
#parent ⇒ Object
The Record which this instance belongs to.
12 13 14 |
# File 'lib/rtp-connect/prescription.rb', line 12 def parent @parent end |
#pattern ⇒ Object
Returns the value of attribute pattern.
27 28 29 |
# File 'lib/rtp-connect/prescription.rb', line 27 def pattern @pattern end |
#rx_depth ⇒ Object
Returns the value of attribute rx_depth.
24 25 26 |
# File 'lib/rtp-connect/prescription.rb', line 24 def rx_depth @rx_depth end |
#rx_note ⇒ Object
Returns the value of attribute rx_note.
28 29 30 |
# File 'lib/rtp-connect/prescription.rb', line 28 def rx_note @rx_note end |
#rx_site_name ⇒ Object
Returns the value of attribute rx_site_name.
20 21 22 |
# File 'lib/rtp-connect/prescription.rb', line 20 def rx_site_name @rx_site_name end |
#simulation_fields ⇒ Object (readonly)
An array of SimulationField records (if any) that belongs to this Prescription.
16 17 18 |
# File 'lib/rtp-connect/prescription.rb', line 16 def simulation_fields @simulation_fields end |
#site_setup ⇒ Object (readonly)
The SiteSetup record (if any) that belongs to this Prescription.
14 15 16 |
# File 'lib/rtp-connect/prescription.rb', line 14 def site_setup @site_setup end |
#technique ⇒ Object
Returns the value of attribute technique.
21 22 23 |
# File 'lib/rtp-connect/prescription.rb', line 21 def technique @technique end |
Class Method Details
.load(string, parent) ⇒ Prescription
Creates a new Prescription site by parsing a RTPConnect string line.
38 39 40 41 |
# File 'lib/rtp-connect/prescription.rb', line 38 def self.load(string, parent) p = self.new(parent) p.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.
82 83 84 85 86 |
# File 'lib/rtp-connect/prescription.rb', line 82 def ==(other) if other.respond_to?(:to_prescription) other.send(:state) == state end end |
#add_field(child) ⇒ Object
Adds a treatment field record to this instance.
94 95 96 97 |
# File 'lib/rtp-connect/prescription.rb', line 94 def add_field(child) @fields << child.to_field child.parent = self end |
#add_simulation_field(child) ⇒ Object
Adds a simulation field record to this instance.
103 104 105 106 |
# File 'lib/rtp-connect/prescription.rb', line 103 def add_simulation_field(child) @simulation_fields << child.to_simulation_field child.parent = self end |
#add_site_setup(child) ⇒ Object
Adds a site setup record to this instance.
112 113 114 115 |
# File 'lib/rtp-connect/prescription.rb', line 112 def add_site_setup(child) @site_setup = child.to_site_setup child.parent = self end |
#children ⇒ Array<SiteSetup, SimulationField, Field>
Collects the child records of this instance in a properly sorted array.
121 122 123 |
# File 'lib/rtp-connect/prescription.rb', line 121 def children return [@site_setup, @simulation_fields, @fields].flatten.compact end |
#delete(record) ⇒ Object
Removes the reference of the given instance from this instance.
129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/rtp-connect/prescription.rb', line 129 def delete(record) case record when Field delete_child(:fields, record) when SimulationField delete_child(:simulation_fields, record) when SiteSetup delete_site_setup else logger.warn("Unknown class (record) given to Prescription#delete: #{record.class}") end end |
#delete_fields ⇒ Object
Removes all field references from this instance.
144 145 146 |
# File 'lib/rtp-connect/prescription.rb', line 144 def delete_fields delete_children(:fields) end |
#delete_simulation_fields ⇒ Object
Removes all simulation_field references from this instance.
150 151 152 |
# File 'lib/rtp-connect/prescription.rb', line 150 def delete_simulation_fields delete_children(:simulation_fields) end |
#delete_site_setup ⇒ Object
Removes the site setup reference from this instance.
156 157 158 |
# File 'lib/rtp-connect/prescription.rb', line 156 def delete_site_setup delete_child(:site_setup) end |
#hash ⇒ Fixnum
Two objects with the same attributes will have the same hash code.
Computes a hash code for this object.
166 167 168 |
# File 'lib/rtp-connect/prescription.rb', line 166 def hash state.hash end |
#to_prescription ⇒ Prescription
Returns self.
174 175 176 |
# File 'lib/rtp-connect/prescription.rb', line 174 def to_prescription self end |