rtp-connect 1.0 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +11 -0
- data/README.rdoc +8 -7
- data/lib/rtp-connect.rb +4 -1
- data/lib/rtp-connect/control_point.rb +76 -82
- data/lib/rtp-connect/extended_field.rb +43 -18
- data/lib/rtp-connect/field.rb +88 -108
- data/lib/rtp-connect/methods.rb +1 -1
- data/lib/rtp-connect/plan.rb +62 -65
- data/lib/rtp-connect/prescription.rb +52 -36
- data/lib/rtp-connect/record.rb +9 -4
- data/lib/rtp-connect/ruby_extensions.rb +1 -1
- data/lib/rtp-connect/site_setup.rb +53 -38
- data/lib/rtp-connect/version.rb +1 -1
- metadata +4 -4
data/lib/rtp-connect/record.rb
CHANGED
@@ -5,6 +5,12 @@ module RTP
|
|
5
5
|
attr_reader :keyword
|
6
6
|
attr_reader :crc
|
7
7
|
|
8
|
+
# Setting the keyword attribute.
|
9
|
+
#
|
10
|
+
def crc=(value)
|
11
|
+
@crc = value.to_s
|
12
|
+
end
|
13
|
+
|
8
14
|
# Encodes a string from the contents of this instance.
|
9
15
|
# This produces the full line, including a computed CRC checksum.
|
10
16
|
#
|
@@ -25,11 +31,10 @@ module RTP
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
#
|
34
|
+
# Returns self.
|
29
35
|
#
|
30
|
-
def
|
31
|
-
|
32
|
-
@crc = value
|
36
|
+
def to_record
|
37
|
+
self
|
33
38
|
end
|
34
39
|
|
35
40
|
end
|
@@ -37,7 +37,7 @@ class String
|
|
37
37
|
# and the resulting quote-less value strings are returned in an array.
|
38
38
|
#
|
39
39
|
def values
|
40
|
-
original =
|
40
|
+
original = CSV.parse(self).first
|
41
41
|
processed = Array.new
|
42
42
|
original.collect {|element| processed << element.gsub('"', '')}
|
43
43
|
return processed
|
@@ -34,10 +34,8 @@ module RTP
|
|
34
34
|
# * <tt>parent</tt> -- A Record which is used to determine the proper parent of this instance.
|
35
35
|
#
|
36
36
|
def self.load(string, parent)
|
37
|
-
raise ArgumentError, "Invalid argument 'string'. Expected String, got #{string.class}." unless string.is_a?(String)
|
38
|
-
raise ArgumentError, "Invalid argument 'parent'. Expected RTP::Prescription, got #{parent.class}." unless parent.is_a?(RTP::Prescription)
|
39
37
|
# Get the quote-less values:
|
40
|
-
values = string.values
|
38
|
+
values = string.to_s.values
|
41
39
|
raise ArgumentError, "Invalid argument 'string': Expected exactly 16 elements, got #{values.length}." unless values.length == 16
|
42
40
|
s = self.new(parent)
|
43
41
|
# Assign the values to attributes:
|
@@ -67,19 +65,34 @@ module RTP
|
|
67
65
|
# * <tt>parent</tt> -- A Record which is used to determine the proper parent of this instance.
|
68
66
|
#
|
69
67
|
def initialize(parent)
|
70
|
-
|
71
|
-
|
72
|
-
@parent = get_parent(parent, Prescription)
|
68
|
+
# Parent relation (always expecting a Prescription here):
|
69
|
+
@parent = get_parent(parent.to_prescription, Prescription)
|
73
70
|
@parent.add_site_setup(self)
|
74
71
|
@keyword = 'SITE_SETUP_DEF'
|
75
72
|
end
|
76
73
|
|
74
|
+
# Returns true if the argument is an instance with attributes equal to self.
|
75
|
+
#
|
76
|
+
def ==(other)
|
77
|
+
if other.respond_to?(:to_site_setup)
|
78
|
+
other.send(:state) == state
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
alias_method :eql?, :==
|
83
|
+
|
77
84
|
# Returns an empty array, as these instances are child-less by definition.
|
78
85
|
#
|
79
86
|
def children
|
80
87
|
return Array.new
|
81
88
|
end
|
82
89
|
|
90
|
+
# Generates a Fixnum hash value for this instance.
|
91
|
+
#
|
92
|
+
def hash
|
93
|
+
state.hash
|
94
|
+
end
|
95
|
+
|
83
96
|
# Returns the values of this instance in an array.
|
84
97
|
# The values does not include the CRC.
|
85
98
|
#
|
@@ -106,122 +119,124 @@ module RTP
|
|
106
119
|
# Writes the SiteSetup object + any hiearchy of child objects,
|
107
120
|
# to a properly formatted RTPConnect ascii string.
|
108
121
|
#
|
109
|
-
def
|
122
|
+
def to_s
|
110
123
|
str = encode
|
111
124
|
if children
|
112
125
|
children.each do |child|
|
113
|
-
str += child.
|
126
|
+
str += child.to_s
|
114
127
|
end
|
115
128
|
end
|
116
129
|
return str
|
117
130
|
end
|
118
131
|
|
132
|
+
alias :to_str :to_s
|
133
|
+
|
134
|
+
# Returns self.
|
135
|
+
#
|
136
|
+
def to_site_setup
|
137
|
+
self
|
138
|
+
end
|
139
|
+
|
119
140
|
# Sets the keyword attribute.
|
120
141
|
#
|
121
142
|
def keyword=(value)
|
122
|
-
|
123
|
-
raise ArgumentError, "Invalid keyword. Expected 'SITE_SETUP_DEF', got #{value}." unless value
|
143
|
+
value = value.to_s.upcase
|
144
|
+
raise ArgumentError, "Invalid keyword. Expected 'SITE_SETUP_DEF', got #{value}." unless value == "SITE_SETUP_DEF"
|
124
145
|
@keyword = value
|
125
146
|
end
|
126
147
|
|
127
148
|
# Sets the rx_site_name attribute.
|
128
149
|
#
|
129
150
|
def rx_site_name=(value)
|
130
|
-
|
131
|
-
@rx_site_name = value
|
151
|
+
@rx_site_name = value && value.to_s
|
132
152
|
end
|
133
153
|
|
134
154
|
# Sets the patient_orientation attribute.
|
135
155
|
#
|
136
156
|
def patient_orientation=(value)
|
137
|
-
|
138
|
-
@patient_orientation = value
|
157
|
+
@patient_orientation = value && value.to_s
|
139
158
|
end
|
140
159
|
|
141
160
|
# Sets the treatment_machine attribute.
|
142
161
|
#
|
143
162
|
def treatment_machine=(value)
|
144
|
-
|
145
|
-
@treatment_machine = value
|
163
|
+
@treatment_machine = value && value.to_s
|
146
164
|
end
|
147
165
|
|
148
166
|
# Sets the tolerance_table attribute.
|
149
167
|
#
|
150
168
|
def tolerance_table=(value)
|
151
|
-
|
152
|
-
@tolerance_table = value
|
169
|
+
@tolerance_table = value && value.to_s
|
153
170
|
end
|
154
171
|
|
155
172
|
# Sets the iso_pos_x attribute.
|
156
173
|
#
|
157
174
|
def iso_pos_x=(value)
|
158
|
-
|
159
|
-
@iso_pos_x = value
|
175
|
+
@iso_pos_x = value && value.to_s
|
160
176
|
end
|
161
177
|
|
162
178
|
# Sets the iso_pos_y attribute.
|
163
179
|
#
|
164
180
|
def iso_pos_y=(value)
|
165
|
-
|
166
|
-
@iso_pos_y = value
|
181
|
+
@iso_pos_y = value && value.to_s
|
167
182
|
end
|
168
183
|
|
169
184
|
# Sets the iso_pos_z attribute.
|
170
185
|
#
|
171
186
|
def iso_pos_z=(value)
|
172
|
-
|
173
|
-
@iso_pos_z = value
|
187
|
+
@iso_pos_z = value && value.to_s
|
174
188
|
end
|
175
189
|
|
176
190
|
# Sets the structure_set_uid attribute.
|
177
191
|
#
|
178
192
|
def structure_set_uid=(value)
|
179
|
-
|
180
|
-
@structure_set_uid = value
|
193
|
+
@structure_set_uid = value && value.to_s
|
181
194
|
end
|
182
195
|
|
183
196
|
# Sets the frame_of_ref_uid attribute.
|
184
197
|
#
|
185
198
|
def frame_of_ref_uid=(value)
|
186
|
-
|
187
|
-
@frame_of_ref_uid = value
|
199
|
+
@frame_of_ref_uid = value && value.to_s
|
188
200
|
end
|
189
201
|
|
190
202
|
# Sets the couch_vertical attribute.
|
191
203
|
#
|
192
204
|
def couch_vertical=(value)
|
193
|
-
|
194
|
-
@couch_vertical = value
|
205
|
+
@couch_vertical = value && value.to_s
|
195
206
|
end
|
196
207
|
|
197
208
|
# Sets the couch_lateral attribute.
|
198
209
|
#
|
199
210
|
def couch_lateral=(value)
|
200
|
-
|
201
|
-
@couch_lateral = value
|
211
|
+
@couch_lateral = value && value.to_s
|
202
212
|
end
|
203
213
|
|
204
214
|
# Sets the couch_longitudinal attribute.
|
205
215
|
#
|
206
216
|
def couch_longitudinal=(value)
|
207
|
-
|
208
|
-
@couch_longitudinal = value
|
217
|
+
@couch_longitudinal = value && value.to_s
|
209
218
|
end
|
210
219
|
|
211
220
|
# Sets the couch_angle attribute.
|
212
221
|
#
|
213
222
|
def couch_angle=(value)
|
214
|
-
|
215
|
-
@couch_angle = value
|
223
|
+
@couch_angle = value && value.to_s
|
216
224
|
end
|
217
225
|
|
218
226
|
# Sets the couch_pedestal attribute.
|
219
227
|
#
|
220
228
|
def couch_pedestal=(value)
|
221
|
-
|
222
|
-
@couch_pedestal = value
|
229
|
+
@couch_pedestal = value && value.to_s
|
223
230
|
end
|
224
231
|
|
232
|
+
|
233
|
+
private
|
234
|
+
|
235
|
+
|
236
|
+
# Returns the attributes of this instance in an array (for comparison purposes).
|
237
|
+
#
|
238
|
+
alias_method :state, :values
|
239
|
+
|
225
240
|
end
|
226
241
|
|
227
242
|
end
|
data/lib/rtp-connect/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rtp-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: "1.
|
5
|
+
version: "1.1"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Christoffer Lervag
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-04-18 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
45
|
+
version: 2.9.0
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.10.
|
56
|
+
version: 0.10.5
|
57
57
|
type: :development
|
58
58
|
version_requirements: *id004
|
59
59
|
description: RTPConnect is a file format used in radiotherapy for export & import of treatment planning data.
|