rtp-connect 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,10 +2,9 @@ module RTP
2
2
 
3
3
  # The SiteSetup class.
4
4
  #
5
- # === Relations
6
- #
7
- # * Parent: Prescription
8
- # * Children: none
5
+ # @note Relations:
6
+ # * Parent: Prescription
7
+ # * Children: none
9
8
  #
10
9
  class SiteSetup < Record
11
10
 
@@ -26,12 +25,12 @@ module RTP
26
25
  attr_reader :couch_angle
27
26
  attr_reader :couch_pedestal
28
27
 
29
- # Creates a new SiteSetup setup by parsing a RTPConnect string line.
30
- #
31
- # === Parameters
28
+ # Creates a new SiteSetup by parsing a RTPConnect string line.
32
29
  #
33
- # * <tt>string</tt> -- A string containing a site setup record.
34
- # * <tt>parent</tt> -- A Record which is used to determine the proper parent of this instance.
30
+ # @param [#to_s] string the site setup definition record string line
31
+ # @param [Record] parent a record which is used to determine the proper parent of this instance
32
+ # @return [SiteSetup] the created SiteSetup instance
33
+ # @raise [ArgumentError] if given a string containing an invalid number of elements
35
34
  #
36
35
  def self.load(string, parent)
37
36
  # Get the quote-less values:
@@ -60,9 +59,7 @@ module RTP
60
59
 
61
60
  # Creates a new SiteSetup.
62
61
  #
63
- # === Parameters
64
- #
65
- # * <tt>parent</tt> -- A Record which is used to determine the proper parent of this instance.
62
+ # @param [Record] parent a record which is used to determine the proper parent of this instance
66
63
  #
67
64
  def initialize(parent)
68
65
  # Parent relation (always expecting a Prescription here):
@@ -71,7 +68,13 @@ module RTP
71
68
  @keyword = 'SITE_SETUP_DEF'
72
69
  end
73
70
 
74
- # Returns true if the argument is an instance with attributes equal to self.
71
+ # Checks for equality.
72
+ #
73
+ # Other and self are considered equivalent if they are
74
+ # of compatible types and their attributes are equivalent.
75
+ #
76
+ # @param other an object to be compared with self.
77
+ # @return [Boolean] true if self and other are considered equivalent
75
78
  #
76
79
  def ==(other)
77
80
  if other.respond_to?(:to_site_setup)
@@ -81,20 +84,28 @@ module RTP
81
84
 
82
85
  alias_method :eql?, :==
83
86
 
84
- # Returns an empty array, as these instances are child-less by definition.
87
+ # Gives an empty array, as these instances are child-less by definition.
88
+ #
89
+ # @return [Array] an emtpy array
85
90
  #
86
91
  def children
87
92
  return Array.new
88
93
  end
89
94
 
90
- # Generates a Fixnum hash value for this instance.
95
+ # Computes a hash code for this object.
96
+ #
97
+ # @note Two objects with the same attributes will have the same hash code.
98
+ #
99
+ # @return [Fixnum] the object's hash code
91
100
  #
92
101
  def hash
93
102
  state.hash
94
103
  end
95
104
 
96
- # Returns the values of this instance in an array.
97
- # The values does not include the CRC.
105
+ # Collects the values (attributes) of this instance.
106
+ #
107
+ # @note The CRC is not considered part of the actual values and is excluded.
108
+ # @return [Array<String>] an array of attributes (in the same order as they appear in the RTP string)
98
109
  #
99
110
  def values
100
111
  return [
@@ -116,9 +127,11 @@ module RTP
116
127
  ]
117
128
  end
118
129
 
119
- # Writes the SiteSetup object + any hiearchy of child objects,
130
+ # Encodes the SiteSetup object + any hiearchy of child objects,
120
131
  # to a properly formatted RTPConnect ascii string.
121
132
  #
133
+ # @return [String] an RTP string with a single or multiple lines/records
134
+ #
122
135
  def to_s
123
136
  str = encode
124
137
  if children
@@ -133,12 +146,18 @@ module RTP
133
146
 
134
147
  # Returns self.
135
148
  #
149
+ # @return [SiteSetup] self
150
+ #
136
151
  def to_site_setup
137
152
  self
138
153
  end
139
154
 
140
155
  # Sets the keyword attribute.
141
156
  #
157
+ # @note Since only a specific string is accepted, this is more of an argument check than a traditional setter method
158
+ # @param [#to_s] value the new attribute value
159
+ # @raise [ArgumentError] if given an unexpected keyword
160
+ #
142
161
  def keyword=(value)
143
162
  value = value.to_s.upcase
144
163
  raise ArgumentError, "Invalid keyword. Expected 'SITE_SETUP_DEF', got #{value}." unless value == "SITE_SETUP_DEF"
@@ -147,93 +166,124 @@ module RTP
147
166
 
148
167
  # Sets the rx_site_name attribute.
149
168
  #
169
+ # @param [nil, #to_s] value the new attribute value
170
+ #
150
171
  def rx_site_name=(value)
151
172
  @rx_site_name = value && value.to_s
152
173
  end
153
174
 
154
175
  # Sets the patient_orientation attribute.
155
176
  #
177
+ # @param [nil, #to_s] value the new attribute value
178
+ #
156
179
  def patient_orientation=(value)
157
180
  @patient_orientation = value && value.to_s
158
181
  end
159
182
 
160
183
  # Sets the treatment_machine attribute.
161
184
  #
185
+ # @param [nil, #to_s] value the new attribute value
186
+ #
162
187
  def treatment_machine=(value)
163
188
  @treatment_machine = value && value.to_s
164
189
  end
165
190
 
166
191
  # Sets the tolerance_table attribute.
167
192
  #
193
+ # @param [nil, #to_s] value the new attribute value
194
+ #
168
195
  def tolerance_table=(value)
169
- @tolerance_table = value && value.to_s
196
+ @tolerance_table = value && value.to_s.strip
170
197
  end
171
198
 
172
199
  # Sets the iso_pos_x attribute.
173
200
  #
201
+ # @param [nil, #to_s] value the new attribute value
202
+ #
174
203
  def iso_pos_x=(value)
175
- @iso_pos_x = value && value.to_s
204
+ @iso_pos_x = value && value.to_s.strip
176
205
  end
177
206
 
178
207
  # Sets the iso_pos_y attribute.
179
208
  #
209
+ # @param [nil, #to_s] value the new attribute value
210
+ #
180
211
  def iso_pos_y=(value)
181
- @iso_pos_y = value && value.to_s
212
+ @iso_pos_y = value && value.to_s.strip
182
213
  end
183
214
 
184
215
  # Sets the iso_pos_z attribute.
185
216
  #
217
+ # @param [nil, #to_s] value the new attribute value
218
+ #
186
219
  def iso_pos_z=(value)
187
- @iso_pos_z = value && value.to_s
220
+ @iso_pos_z = value && value.to_s.strip
188
221
  end
189
222
 
190
223
  # Sets the structure_set_uid attribute.
191
224
  #
225
+ # @param [nil, #to_s] value the new attribute value
226
+ #
192
227
  def structure_set_uid=(value)
193
228
  @structure_set_uid = value && value.to_s
194
229
  end
195
230
 
196
231
  # Sets the frame_of_ref_uid attribute.
197
232
  #
233
+ # @param [nil, #to_s] value the new attribute value
234
+ #
198
235
  def frame_of_ref_uid=(value)
199
236
  @frame_of_ref_uid = value && value.to_s
200
237
  end
201
238
 
202
239
  # Sets the couch_vertical attribute.
203
240
  #
241
+ # @param [nil, #to_s] value the new attribute value
242
+ #
204
243
  def couch_vertical=(value)
205
- @couch_vertical = value && value.to_s
244
+ @couch_vertical = value && value.to_s.strip
206
245
  end
207
246
 
208
247
  # Sets the couch_lateral attribute.
209
248
  #
249
+ # @param [nil, #to_s] value the new attribute value
250
+ #
210
251
  def couch_lateral=(value)
211
- @couch_lateral = value && value.to_s
252
+ @couch_lateral = value && value.to_s.strip
212
253
  end
213
254
 
214
255
  # Sets the couch_longitudinal attribute.
215
256
  #
257
+ # @param [nil, #to_s] value the new attribute value
258
+ #
216
259
  def couch_longitudinal=(value)
217
- @couch_longitudinal = value && value.to_s
260
+ @couch_longitudinal = value && value.to_s.strip
218
261
  end
219
262
 
220
263
  # Sets the couch_angle attribute.
221
264
  #
265
+ # @param [nil, #to_s] value the new attribute value
266
+ #
222
267
  def couch_angle=(value)
223
- @couch_angle = value && value.to_s
268
+ @couch_angle = value && value.to_s.strip
224
269
  end
225
270
 
226
271
  # Sets the couch_pedestal attribute.
227
272
  #
273
+ # @param [nil, #to_s] value the new attribute value
274
+ #
228
275
  def couch_pedestal=(value)
229
- @couch_pedestal = value && value.to_s
276
+ @couch_pedestal = value && value.to_s.strip
230
277
  end
231
278
 
232
279
 
233
280
  private
234
281
 
235
282
 
236
- # Returns the attributes of this instance in an array (for comparison purposes).
283
+ # Collects the attributes of this instance.
284
+ #
285
+ # @note The CRC is not considered part of the attributes of interest and is excluded
286
+ # @return [Array<String>] an array of attributes
237
287
  #
238
288
  alias_method :state, :values
239
289
 
@@ -1,6 +1,6 @@
1
- module RTP
2
-
3
- # The RTPConnect library version string.
4
- VERSION = "1.1"
5
-
1
+ module RTP
2
+
3
+ # The RTPConnect library version string.
4
+ VERSION = "1.2"
5
+
6
6
  end
data/rakefile.rb ADDED
@@ -0,0 +1,29 @@
1
+ # Available commands:
2
+ # Testing the specification:
3
+ # bundle exec rake spec
4
+ # Building a gem package from source:
5
+ # bundle exec rake package
6
+ # Create html documentation files:
7
+ # bundle exec rake yard
8
+
9
+ require 'rubygems/package_task'
10
+ require 'rspec/core/rake_task'
11
+ require 'yard'
12
+
13
+ # Build gem:
14
+ gem_spec = eval(File.read('rtp-connect.gemspec'))
15
+ Gem::PackageTask.new(gem_spec) do |pkg|
16
+ pkg.gem_spec = gem_spec
17
+ #pkg.need_tar = true
18
+ end
19
+
20
+ # RSpec 2:
21
+ RSpec::Core::RakeTask.new do |t|
22
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
23
+ t.pattern = 'spec/**/*_spec.rb'
24
+ end
25
+
26
+ # Build documentation (YARD):
27
+ YARD::Rake::YardocTask.new do |t|
28
+ t.options += ['--title', "RTP-Connect #{RTP::VERSION} Documentation"]
29
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+
3
+ require File.expand_path('../lib/rtp-connect/version', __FILE__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.platform = Gem::Platform::RUBY
7
+ s.name = 'rtp-connect'
8
+ s.version = RTP::VERSION
9
+ s.date = Time.now
10
+ s.summary = "Library for handling RTPConnect files."
11
+ s.require_paths = ['lib']
12
+ s.author = "Christoffer Lervag"
13
+ s.email = "chris.lervag@gmail.com"
14
+ s.homepage = "https://github.com/dicom/rtp-connect"
15
+ s.license = "GPLv3"
16
+ s.description = "RTPConnect is a file format used in radiotherapy for export & import of treatment planning data."
17
+ s.files = Dir["{lib}/**/*", "[A-Z]*"]
18
+ s.rubyforge_project = 'rtp-connect'
19
+
20
+ s.required_ruby_version = '>= 1.9.2'
21
+ s.required_rubygems_version = '>= 1.8.6'
22
+
23
+ s.add_development_dependency('bundler', '>= 1.0.0')
24
+ s.add_development_dependency('dicom', '>= 0.9.3')
25
+ s.add_development_dependency('rake', '>= 0.9.2.2')
26
+ s.add_development_dependency('rspec', '>= 2.9.0')
27
+ s.add_development_dependency('mocha', '>= 0.10.5')
28
+ s.add_development_dependency('yard', '>= 0.8.2')
29
+ end
metadata CHANGED
@@ -1,77 +1,128 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rtp-connect
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.2'
4
5
  prerelease:
5
- version: "1.1"
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Christoffer Lervag
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-04-18 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :development
17
23
  prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
19
25
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
23
29
  version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: dicom
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.9.3
24
38
  type: :development
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: rake
28
39
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
30
41
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
34
53
  version: 0.9.2.2
35
54
  type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rspec
39
55
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
41
65
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
45
69
  version: 2.9.0
46
70
  type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 2.9.0
78
+ - !ruby/object:Gem::Dependency
49
79
  name: mocha
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 0.10.5
86
+ type: :development
50
87
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
52
89
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
56
93
  version: 0.10.5
94
+ - !ruby/object:Gem::Dependency
95
+ name: yard
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 0.8.2
57
102
  type: :development
58
- version_requirements: *id004
59
- description: RTPConnect is a file format used in radiotherapy for export & import of treatment planning data.
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.8.2
110
+ description: RTPConnect is a file format used in radiotherapy for export & import
111
+ of treatment planning data.
60
112
  email: chris.lervag@gmail.com
61
113
  executables: []
62
-
63
114
  extensions: []
64
-
65
115
  extra_rdoc_files: []
66
-
67
- files:
116
+ files:
68
117
  - lib/rtp-connect/constants.rb
69
118
  - lib/rtp-connect/control_point.rb
119
+ - lib/rtp-connect/dose_tracking.rb
70
120
  - lib/rtp-connect/extended_field.rb
71
121
  - lib/rtp-connect/field.rb
72
122
  - lib/rtp-connect/logging.rb
73
123
  - lib/rtp-connect/methods.rb
74
124
  - lib/rtp-connect/plan.rb
125
+ - lib/rtp-connect/plan_to_dcm.rb
75
126
  - lib/rtp-connect/prescription.rb
76
127
  - lib/rtp-connect/record.rb
77
128
  - lib/rtp-connect/ruby_extensions.rb
@@ -81,33 +132,34 @@ files:
81
132
  - lib/rtp-connect.rb
82
133
  - CHANGELOG.rdoc
83
134
  - COPYING
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - rakefile.rb
84
138
  - README.rdoc
139
+ - rtp-connect.gemspec
85
140
  homepage: https://github.com/dicom/rtp-connect
86
- licenses:
87
- - GPL3
141
+ licenses:
142
+ - GPLv3
88
143
  post_install_message:
89
144
  rdoc_options: []
90
-
91
- require_paths:
145
+ require_paths:
92
146
  - lib
93
- required_ruby_version: !ruby/object:Gem::Requirement
147
+ required_ruby_version: !ruby/object:Gem::Requirement
94
148
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
98
152
  version: 1.9.2
99
- required_rubygems_version: !ruby/object:Gem::Requirement
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
154
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
104
158
  version: 1.8.6
105
159
  requirements: []
106
-
107
160
  rubyforge_project: rtp-connect
108
- rubygems_version: 1.8.13
161
+ rubygems_version: 1.8.24
109
162
  signing_key:
110
163
  specification_version: 3
111
164
  summary: Library for handling RTPConnect files.
112
165
  test_files: []
113
-