rtp-connect 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,158 +1,155 @@
1
- module RTP
2
-
3
- # This module handles logging functionality.
4
- #
5
- # Logging functionality uses the Standard library's Logger class.
6
- # To properly handle progname, which inside the RTP module is simply
7
- # "RTP", in all cases, we use an implementation with a proxy class.
8
- #
9
- # === Examples
10
- #
11
- # require 'rtp-connect'
12
- # include RTP
13
- #
14
- # # Logging to STDOUT with DEBUG level:
15
- # RTP.logger = Logger.new(STDOUT)
16
- # RTP.logger.level = Logger::DEBUG
17
- #
18
- # # Logging to a file:
19
- # RTP.logger = Logger.new('my_logfile.log')
20
- #
21
- # # Combine an external logger with RTP:
22
- # logger = Logger.new(STDOUT)
23
- # logger.progname = "MY_APP"
24
- # RTP.logger = logger
25
- # # Now you can call the logger in the following ways:
26
- # RTP.logger.info "Message" # => "RTP: Message"
27
- # RTP.logger.info("MY_MODULE) {"Message"} # => "MY_MODULE: Message"
28
- # logger.info "Message" # => "MY_APP: Message"
29
- #
30
- # For more information, please read the Standard library Logger documentation.
31
- #
32
- module Logging
33
-
34
- require 'logger'
35
-
36
- # Inclusion hook to make the ClassMethods available to whatever
37
- # includes the Logging module, i.e. the RTP module.
38
- #
39
- def self.included(base)
40
- base.extend(ClassMethods)
41
- end
42
-
43
- module ClassMethods
44
-
45
- # We use our own ProxyLogger to achieve the features wanted for RTP logging,
46
- # e.g. using RTP as progname for messages logged within the RTP module
47
- # (for both the Standard logger as well as the Rails logger), while still allowing
48
- # a custom progname to be used when the logger is called outside the RTP module.
49
- #
50
- class ProxyLogger
51
-
52
- # Creating the ProxyLogger instance.
53
- #
54
- # === Parameters
55
- #
56
- # * <tt>target</tt> -- A Logger instance (e.g. Standard Logger or ActiveSupport::BufferedLogger).
57
- #
58
- def initialize(target)
59
- @target = target
60
- end
61
-
62
- # Catches missing methods.
63
- # In our case, the methods of interest are the typical logger methods,
64
- # i.e. log, info, fatal, error, debug, where the arguments/block are
65
- # redirected to the logger in a specific way so that our stated logger
66
- # features are achieved (this behaviour depends on the logger
67
- # (Rails vs Standard) and in the case of Standard logger,
68
- # whether or not a block is given).
69
- #
70
- # === Examples
71
- #
72
- # # Inside the RTP module or an external class with 'include RTP::Logging':
73
- # logger.info "message"
74
- #
75
- # # Calling from outside the RTP module:
76
- # RTP.logger.info "message"
77
- #
78
- def method_missing(method_name, *args, &block)
79
- if method_name.to_s =~ /(log|debug|info|warn|error|fatal)/
80
- # Rails uses it's own buffered logger which does not
81
- # work with progname + block as the standard logger does:
82
- if defined?(Rails)
83
- @target.send(method_name, "RTP: #{args.first}")
84
- elsif block_given?
85
- @target.send(method_name, *args) { yield }
86
- else
87
- @target.send(method_name, "RTP") { args.first }
88
- end
89
- else
90
- @target.send(method_name, *args, &block)
91
- end
92
- end
93
-
94
- end
95
-
96
- # The logger class variable (must be initialized
97
- # before it is referenced by the object setter).
98
- #
99
- @@logger = nil
100
-
101
- # The logger object setter.
102
- # This method is used to replace the default logger instance with
103
- # a custom logger of your own.
104
- #
105
- # === Parameters
106
- #
107
- # * <tt>l</tt> -- A Logger instance (e.g. a custom standard Logger).
108
- #
109
- # === Examples
110
- #
111
- # # Create a logger which ages logfile once it reaches a certain size,
112
- # # leaves 10 "old log files" with each file being about 1,024,000 bytes:
113
- # RTP.logger = Logger.new('foo.log', 10, 1024000)
114
- #
115
- def logger=(l)
116
- @@logger = ProxyLogger.new(l)
117
- end
118
-
119
- # The logger object getter.
120
- # Returns the logger class variable, if defined.
121
- # If not defined, sets up the Rails logger (if in a Rails environment),
122
- # or a Standard logger if not.
123
- #
124
- # === Examples
125
- #
126
- # # Inside the RTP module (or a class with 'include RTP::Logging'):
127
- # logger # => Logger instance
128
- #
129
- # # Accessing from outside the RTP module:
130
- # RTP.logger # => Logger instance
131
- #
132
- def logger
133
- @@logger ||= lambda {
134
- if defined?(Rails)
135
- ProxyLogger.new(Rails.logger)
136
- else
137
- l = Logger.new(STDOUT)
138
- l.level = Logger::INFO
139
- ProxyLogger.new(l)
140
- end
141
- }.call
142
- end
143
-
144
- end
145
-
146
- # A logger object getter.
147
- # Forwards the call to the logger class method of the Logging module.
148
- #
149
- def logger
150
- self.class.logger
151
- end
152
-
153
- end
154
-
155
- # Include the Logging module so we can use RTP.logger.
156
- include Logging
157
-
158
- end
1
+ module RTP
2
+
3
+ # This module handles logging functionality.
4
+ #
5
+ # Logging functionality uses the Standard library's Logger class.
6
+ # To properly handle progname, which inside the RTP module is simply
7
+ # "RTP", in all cases, we use an implementation with a proxy class.
8
+ #
9
+ # @note For more information, please read the Standard library Logger documentation.
10
+ #
11
+ # @example Various logger use cases:
12
+ # require 'rtp-connect'
13
+ # include RTP
14
+ #
15
+ # # Logging to STDOUT with DEBUG level:
16
+ # RTP.logger = Logger.new(STDOUT)
17
+ # RTP.logger.level = Logger::DEBUG
18
+ #
19
+ # # Logging to a file:
20
+ # RTP.logger = Logger.new('my_logfile.log')
21
+ #
22
+ # # Combine an external logger with RTP:
23
+ # logger = Logger.new(STDOUT)
24
+ # logger.progname = "MY_APP"
25
+ # RTP.logger = logger
26
+ # # Now you can call the logger in the following ways:
27
+ # RTP.logger.info "Message" # => "RTP: Message"
28
+ # RTP.logger.info("MY_MODULE) {"Message"} # => "MY_MODULE: Message"
29
+ # logger.info "Message" # => "MY_APP: Message"
30
+ #
31
+ module Logging
32
+
33
+ require 'logger'
34
+
35
+ # Inclusion hook to make the ClassMethods available to whatever
36
+ # includes the Logging module, i.e. the RTP module.
37
+ #
38
+ def self.included(base)
39
+ base.extend(ClassMethods)
40
+ end
41
+
42
+ # Class methods which the Logging module is extended with.
43
+ #
44
+ module ClassMethods
45
+
46
+ # We use our own ProxyLogger to achieve the features wanted for RTP logging,
47
+ # e.g. using RTP as progname for messages logged within the RTP module
48
+ # (for both the Standard logger as well as the Rails logger), while still allowing
49
+ # a custom progname to be used when the logger is called outside the RTP module.
50
+ #
51
+ class ProxyLogger
52
+
53
+ # Creating the ProxyLogger instance.
54
+ #
55
+ # @param [Logger] target a logger instance (e.g. Standard Logger or ActiveSupport::BufferedLogger)
56
+ #
57
+ def initialize(target)
58
+ @target = target
59
+ end
60
+
61
+ # Catches missing methods.
62
+ #
63
+ # In our case, the methods of interest are the typical logger methods,
64
+ # i.e. log, info, fatal, error, debug, where the arguments/block are
65
+ # redirected to the logger in a specific way so that our stated logger
66
+ # features are achieved (this behaviour depends on the logger
67
+ # (Rails vs Standard) and in the case of Standard logger,
68
+ # whether or not a block is given).
69
+ #
70
+ # @example Inside the RTP module or an external class with 'include RTP::Logging':
71
+ # logger.info "message"
72
+ #
73
+ # @example Calling from outside the RTP module:
74
+ # RTP.logger.info "message"
75
+ #
76
+ def method_missing(method_name, *args, &block)
77
+ if method_name.to_s =~ /(log|debug|info|warn|error|fatal)/
78
+ # Rails uses it's own buffered logger which does not
79
+ # work with progname + block as the standard logger does:
80
+ if defined?(Rails)
81
+ @target.send(method_name, "RTP: #{args.first}")
82
+ elsif block_given?
83
+ @target.send(method_name, *args) { yield }
84
+ else
85
+ @target.send(method_name, "RTP") { args.first }
86
+ end
87
+ else
88
+ @target.send(method_name, *args, &block)
89
+ end
90
+ end
91
+
92
+ end
93
+
94
+ # The logger class variable (must be initialized
95
+ # before it is referenced by the object setter).
96
+ #
97
+ @@logger = nil
98
+
99
+ # The logger object getter.
100
+ #
101
+ # If a logger instance is not pre-defined, it sets up a Standard
102
+ # logger or (if in a Rails environment) the Rails logger.
103
+ #
104
+ # @example Inside the RTP module (or a class with 'include RTP::Logging'):
105
+ # logger # => Logger instance
106
+ #
107
+ # @example Accessing from outside the RTP module:
108
+ # RTP.logger # => Logger instance
109
+ #
110
+ # @return [ProxyLogger] the logger class variable
111
+ #
112
+ def logger
113
+ @@logger ||= lambda {
114
+ if defined?(Rails)
115
+ ProxyLogger.new(Rails.logger)
116
+ else
117
+ l = Logger.new(STDOUT)
118
+ l.level = Logger::INFO
119
+ ProxyLogger.new(l)
120
+ end
121
+ }.call
122
+ end
123
+
124
+ # The logger object setter.
125
+ # This method is used to replace the default logger instance with
126
+ # a custom logger of your own.
127
+ #
128
+ # @param [Logger] l a logger instance
129
+ #
130
+ # @example Multiple log files
131
+ # # Create a logger which ages logfile once it reaches a certain size,
132
+ # # leaving 10 "old log files" with each file being about 1,024,000 bytes:
133
+ # RTP.logger = Logger.new('foo.log', 10, 1024000)
134
+ #
135
+ def logger=(l)
136
+ @@logger = ProxyLogger.new(l)
137
+ end
138
+
139
+ end
140
+
141
+ # A logger object getter.
142
+ # Forwards the call to the logger class method of the Logging module.
143
+ #
144
+ # @return [ProxyLogger] the logger class variable
145
+ #
146
+ def logger
147
+ self.class.logger
148
+ end
149
+
150
+ end
151
+
152
+ # Include the Logging module so we can use RTP.logger.
153
+ include Logging
154
+
155
+ end
@@ -8,11 +8,10 @@ module RTP
8
8
 
9
9
  # Computes the CRC checksum of the given line and verifies that
10
10
  # this value corresponds with the checksum given at the end of the line.
11
- # Raises an error if the two values does not match.
12
11
  #
13
- # === Parameters
14
- #
15
- # * <tt>line</tt> -- An single line string from an RTPConnect ascii file.
12
+ # @param [String] line a single line string from an RTPConnect ascii file
13
+ # @return [Boolean] true
14
+ # @raise [ArgumentError] if an invalid line/record is given or the string contains an invalid checksum
16
15
  #
17
16
  def verify(line)
18
17
  last_comma_pos = line.rindex(',')
@@ -1,4 +1,4 @@
1
- # Copyright 2011 Christoffer Lervag
1
+ # Copyright 2011-2012 Christoffer Lervag
2
2
  #
3
3
  # This program is free software: you can redistribute it and/or modify
4
4
  # it under the terms of the GNU General Public License as published by
@@ -15,18 +15,17 @@
15
15
  #
16
16
  module RTP
17
17
 
18
- # The Plan class is the highest level of objects in the RTPConnect hierarchy,
18
+ # The Plan class is the highest level Record in the RTPConnect records hierarchy,
19
19
  # and the one the user will interact with to read, modify and write files.
20
20
  #
21
- # === Relations
22
- #
23
- # * Parent: none
24
- # * Children: Prescription, DoseTracking
21
+ # @note Relations:
22
+ # * Parent: nil
23
+ # * Children: Prescription, DoseTracking
25
24
  #
26
25
  class Plan < Record
27
26
  include Logging
28
27
 
29
- # The Record which this instance belongs to (nil by definition)
28
+ # The Record which this instance belongs to (nil by definition).
30
29
  attr_reader :parent
31
30
  # An array of Prescription records (if any) that belongs to this Plan.
32
31
  attr_reader :prescriptions
@@ -61,14 +60,11 @@ module RTP
61
60
 
62
61
  # Creates a new Plan by loading a plan definition string (i.e. a single line).
63
62
  #
64
- # === Notes
65
- #
66
- # * This method does not perform crc verification on the given string.
67
- # * If such verification is desired, use methods ::parse or ::read instead.
68
- #
69
- # === Parameters
70
- #
71
- # * <tt>string</tt> -- A string containing a plan definition record.
63
+ # @note This method does not perform crc verification on the given string.
64
+ # If such verification is desired, use methods ::parse or ::read instead.
65
+ # @param [#to_s] string the plan definition record string line
66
+ # @return [Plan] the created Plan instance
67
+ # @raise [ArgumentError] if given a string containing an invalid number of elements
72
68
  #
73
69
  def self.load(string)
74
70
  # Get the quote-less values:
@@ -107,12 +103,11 @@ module RTP
107
103
  return rtp
108
104
  end
109
105
 
110
- # Creates an RTP::Plan instance by parsing a RTPConnect string
111
- # (i.e. multiple lines, containing multiple definitions).
106
+ # Creates a Plan instance by parsing an RTPConnect string.
112
107
  #
113
- # === Parameters
114
- #
115
- # * <tt>string</tt> -- An RTPConnect ascii string.
108
+ # @param [#to_s] string an RTPConnect ascii string (with single or multiple lines/records)
109
+ # @return [Plan] the created Plan instance
110
+ # @raise [ArgumentError] if given an invalid string record
116
111
  #
117
112
  def self.parse(string)
118
113
  lines = string.to_s.split("\r\n")
@@ -133,11 +128,11 @@ module RTP
133
128
  return rtp
134
129
  end
135
130
 
136
- # Creates an RTP::Plan instance by reading and parsing an RTPConnect file.
137
- #
138
- # === Parameters
131
+ # Creates an Plan instance by reading and parsing an RTPConnect file.
139
132
  #
140
- # * <tt>file</tt> -- A string which specifies the path of the RTPConnect file to be loaded.
133
+ # @param [String] file a string which specifies the path of the RTPConnect file to be loaded
134
+ # @return [Plan] the created Plan instance
135
+ # @raise [ArgumentError] if given an invalid file or the file given contains an invalid record
141
136
  #
142
137
  def self.read(file)
143
138
  raise ArgumentError, "Invalid argument 'file'. Expected String, got #{file.class}." unless file.is_a?(String)
@@ -181,7 +176,13 @@ module RTP
181
176
  @keyword = 'PLAN_DEF'
182
177
  end
183
178
 
184
- # Returns true if the argument is an instance with attributes equal to self.
179
+ # Checks for equality.
180
+ #
181
+ # Other and self are considered equivalent if they are
182
+ # of compatible types and their attributes are equivalent.
183
+ #
184
+ # @param other an object to be compared with self.
185
+ # @return [Boolean] true if self and other are considered equivalent
185
186
  #
186
187
  def ==(other)
187
188
  if other.respond_to?(:to_plan)
@@ -191,26 +192,44 @@ module RTP
191
192
 
192
193
  alias_method :eql?, :==
193
194
 
195
+ # Adds a dose tracking record to this instance.
196
+ #
197
+ # @param [DoseTracking] child a DoseTracking instance which is to be associated with self
198
+ #
199
+ def add_dose_tracking(child)
200
+ @dose_trackings << child.to_dose_tracking
201
+ end
202
+
194
203
  # Adds a prescription site record to this instance.
195
204
  #
205
+ # @param [Prescription] child a Prescription instance which is to be associated with self
206
+ #
196
207
  def add_prescription(child)
197
208
  @prescriptions << child.to_prescription
198
209
  end
199
210
 
200
- # Returns the a properly sorted array of the child records of this instance.
211
+ # Collects the child records of this instance in a properly sorted array.
212
+ #
213
+ # @return [Array<Prescription, DoseTracking>] a sorted array of self's child records
201
214
  #
202
215
  def children
203
216
  return [@prescriptions, @dose_trackings].flatten.compact
204
217
  end
205
218
 
206
- # Generates a Fixnum hash value for this instance.
219
+ # Computes a hash code for this object.
220
+ #
221
+ # @note Two objects with the same attributes will have the same hash code.
222
+ #
223
+ # @return [Fixnum] the object's hash code
207
224
  #
208
225
  def hash
209
226
  state.hash
210
227
  end
211
228
 
212
- # Returns the values of this instance in an array.
213
- # The values does not include the CRC.
229
+ # Collects the values (attributes) of this instance.
230
+ #
231
+ # @note The CRC is not considered part of the actual values and is excluded.
232
+ # @return [Array<String>] an array of attributes (in the same order as they appear in the RTP string)
214
233
  #
215
234
  def values
216
235
  return [
@@ -246,13 +265,25 @@ module RTP
246
265
 
247
266
  # Returns self.
248
267
  #
268
+ # @return [Plan] self
269
+ #
249
270
  def to_plan
250
271
  self
251
272
  end
252
273
 
253
- # Writes the Plan object + any hiearchy of child objects,
274
+ # Returns self.
275
+ #
276
+ # @return [Plan] self
277
+ #
278
+ def to_rtp
279
+ self
280
+ end
281
+
282
+ # Encodes the Plan object + any hiearchy of child objects,
254
283
  # to a properly formatted RTPConnect ascii string.
255
284
  #
285
+ # @return [String] an RTP string with a single or multiple lines/records
286
+ #
256
287
  def to_s
257
288
  str = encode #.force_encoding('utf-8')
258
289
  children.each do |child|
@@ -266,9 +297,7 @@ module RTP
266
297
  # Writes the Plan object, along with its hiearchy of child objects,
267
298
  # to a properly formatted RTPConnect ascii file.
268
299
  #
269
- # === Parameters
270
- #
271
- # * <tt>file</tt> -- A path/file string.
300
+ # @param [String] file a path/file string
272
301
  #
273
302
  def write(file)
274
303
  f = open_file(file)
@@ -278,6 +307,10 @@ module RTP
278
307
 
279
308
  # Sets the keyword attribute.
280
309
  #
310
+ # @note Since only a specific string is accepted, this is more of an argument check than a traditional setter method
311
+ # @param [#to_s] value the new attribute value
312
+ # @raise [ArgumentError] if given an unexpected keyword
313
+ #
281
314
  def keyword=(value)
282
315
  value = value.to_s.upcase
283
316
  raise ArgumentError, "Invalid keyword. Expected 'PLAN_DEF', got #{value}." unless value == "PLAN_DEF"
@@ -286,6 +319,8 @@ module RTP
286
319
 
287
320
  # Sets the patient_id attribute.
288
321
  #
322
+ # @param [nil, #to_s] value the new attribute value
323
+ #
289
324
  def patient_id=(value)
290
325
  @patient_id = value && value.to_s
291
326
  end
@@ -298,144 +333,192 @@ module RTP
298
333
 
299
334
  # Sets the patient_first_name attribute.
300
335
  #
336
+ # @param [nil, #to_s] value the new attribute value
337
+ #
301
338
  def patient_first_name=(value)
302
339
  @patient_first_name = value && value.to_s
303
340
  end
304
341
 
305
342
  # Sets the patient_middle_initial attribute.
306
343
  #
344
+ # @param [nil, #to_s] value the new attribute value
345
+ #
307
346
  def patient_middle_initial=(value)
308
347
  @patient_middle_initial = value && value.to_s
309
348
  end
310
349
 
311
350
  # Sets the plan_id attribute.
312
351
  #
352
+ # @param [nil, #to_s] value the new attribute value
353
+ #
313
354
  def plan_id=(value)
314
355
  @plan_id = value && value.to_s
315
356
  end
316
357
 
317
358
  # Sets the plan_date attribute.
318
359
  #
360
+ # @param [nil, #to_s] value the new attribute value
361
+ #
319
362
  def plan_date=(value)
320
363
  @plan_date = value && value.to_s
321
364
  end
322
365
 
323
366
  # Sets the plan_time attribute.
324
367
  #
368
+ # @param [nil, #to_s] value the new attribute value
369
+ #
325
370
  def plan_time=(value)
326
371
  @plan_time = value && value.to_s
327
372
  end
328
373
 
329
374
  # Sets the course_id attribute.
330
375
  #
376
+ # @param [nil, #to_s] value the new attribute value
377
+ #
331
378
  def course_id=(value)
332
379
  @course_id = value && value.to_s
333
380
  end
334
381
 
335
382
  # Sets the diagnosis attribute.
336
383
  #
384
+ # @param [nil, #to_s] value the new attribute value
385
+ #
337
386
  def diagnosis=(value)
338
387
  @diagnosis = value && value.to_s
339
388
  end
340
389
 
341
390
  # Sets the md_last_name attribute.
342
391
  #
392
+ # @param [nil, #to_s] value the new attribute value
393
+ #
343
394
  def md_last_name=(value)
344
395
  @md_last_name = value && value.to_s
345
396
  end
346
397
 
347
398
  # Sets the md_first_name attribute.
348
399
  #
400
+ # @param [nil, #to_s] value the new attribute value
401
+ #
349
402
  def md_first_name=(value)
350
403
  @md_first_name = value && value.to_s
351
404
  end
352
405
 
353
406
  # Sets the md_middle_initial attribute.
354
407
  #
408
+ # @param [nil, #to_s] value the new attribute value
409
+ #
355
410
  def md_middle_initial=(value)
356
411
  @md_middle_initial = value && value.to_s
357
412
  end
358
413
 
359
414
  # Sets the md_approve_last_name attribute.
360
415
  #
416
+ # @param [nil, #to_s] value the new attribute value
417
+ #
361
418
  def md_approve_last_name=(value)
362
419
  @md_approve_last_name = value && value.to_s
363
420
  end
364
421
 
365
422
  # Sets the md_approve_first_name attribute.
366
423
  #
424
+ # @param [nil, #to_s] value the new attribute value
425
+ #
367
426
  def md_approve_first_name=(value)
368
427
  @md_approve_first_name = value && value.to_s
369
428
  end
370
429
 
371
430
  # Sets the md_approve_middle_initial attribute.
372
431
  #
432
+ # @param [nil, #to_s] value the new attribute value
433
+ #
373
434
  def md_approve_middle_initial=(value)
374
435
  @md_approve_middle_initial = value && value.to_s
375
436
  end
376
437
 
377
438
  # Sets the phy_approve_last_name attribute.
378
439
  #
440
+ # @param [nil, #to_s] value the new attribute value
441
+ #
379
442
  def phy_approve_last_name=(value)
380
443
  @phy_approve_last_name = value && value.to_s
381
444
  end
382
445
 
383
446
  # Sets the phy_approve_first_name attribute.
384
447
  #
448
+ # @param [nil, #to_s] value the new attribute value
449
+ #
385
450
  def phy_approve_first_name=(value)
386
451
  @phy_approve_first_name = value && value.to_s
387
452
  end
388
453
 
389
454
  # Sets the phy_approve_middle_initial attribute.
390
455
  #
456
+ # @param [nil, #to_s] value the new attribute value
457
+ #
391
458
  def phy_approve_middle_initial=(value)
392
459
  @phy_approve_middle_initial = value && value.to_s
393
460
  end
394
461
 
395
462
  # Sets the author_last_name attribute.
396
463
  #
464
+ # @param [nil, #to_s] value the new attribute value
465
+ #
397
466
  def author_last_name=(value)
398
467
  @author_last_name = value && value.to_s
399
468
  end
400
469
 
401
470
  # Sets the author_first_name attribute.
402
471
  #
472
+ # @param [nil, #to_s] value the new attribute value
473
+ #
403
474
  def author_first_name=(value)
404
475
  @author_first_name = value && value.to_s
405
476
  end
406
477
 
407
478
  # Sets the author_middle_initial attribute.
408
479
  #
480
+ # @param [nil, #to_s] value the new attribute value
481
+ #
409
482
  def author_middle_initial=(value)
410
483
  @author_middle_initial = value && value.to_s
411
484
  end
412
485
 
413
486
  # Sets the rtp_mfg attribute.
414
487
  #
488
+ # @param [nil, #to_s] value the new attribute value
489
+ #
415
490
  def rtp_mfg=(value)
416
491
  @rtp_mfg = value && value.to_s
417
492
  end
418
493
 
419
494
  # Sets the rtp_model attribute.
420
495
  #
496
+ # @param [nil, #to_s] value the new attribute value
497
+ #
421
498
  def rtp_model=(value)
422
499
  @rtp_model = value && value.to_s
423
500
  end
424
501
 
425
502
  # Sets the rtp_version attribute.
426
503
  #
504
+ # @param [nil, #to_s] value the new attribute value
505
+ #
427
506
  def rtp_version=(value)
428
507
  @rtp_version = value && value.to_s
429
508
  end
430
509
 
431
510
  # Sets the rtp_if_protocol attribute.
432
511
  #
512
+ # @param [nil, #to_s] value the new attribute value
513
+ #
433
514
  def rtp_if_protocol=(value)
434
515
  @rtp_if_protocol = value && value.to_s
435
516
  end
436
517
 
437
518
  # Sets the rtp_if_version attribute.
438
519
  #
520
+ # @param [nil, #to_s] value the new attribute value
521
+ #
439
522
  def rtp_if_version=(value)
440
523
  @rtp_if_version = value && value.to_s
441
524
  end
@@ -446,20 +529,25 @@ module RTP
446
529
 
447
530
  # Creates a control point record from the given string.
448
531
  #
449
- # === Parameters
450
- #
451
- # * <tt>string</tt> -- An single line string from an RTPConnect ascii file.
532
+ # @param [String] string a string line containing a control point definition
452
533
  #
453
534
  def control_point(string)
454
535
  cp = ControlPoint.load(string, @current_parent)
455
536
  @current_parent = cp
456
537
  end
457
538
 
458
- # Creates an extended treatment field record from the given string.
539
+ # Creates a dose tracking record from the given string.
459
540
  #
460
- # === Parameters
541
+ # @param [String] string a string line containing a dose tracking definition
461
542
  #
462
- # * <tt>string</tt> -- An single line string from an RTPConnect ascii file.
543
+ def dose_tracking(string)
544
+ dt = DoseTracking.load(string, @current_parent)
545
+ @current_parent = dt
546
+ end
547
+
548
+ # Creates an extended treatment field record from the given string.
549
+ #
550
+ # @param [String] string a string line containing an extended treatment field definition
463
551
  #
464
552
  def extended_treatment_field(string)
465
553
  ef = ExtendedField.load(string, @current_parent)
@@ -468,9 +556,8 @@ module RTP
468
556
 
469
557
  # Tests if the path/file is writable, creates any folders if necessary, and opens the file for writing.
470
558
  #
471
- # === Parameters
472
- #
473
- # * <tt>file</tt> -- A path/file string.
559
+ # @param [String] file a path/file string
560
+ # @raise if the given file cannot be created
474
561
  #
475
562
  def open_file(file)
476
563
  # Check if file already exists:
@@ -502,9 +589,7 @@ module RTP
502
589
 
503
590
  # Creates a prescription site record from the given string.
504
591
  #
505
- # === Parameters
506
- #
507
- # * <tt>string</tt> -- An single line string from an RTPConnect ascii file.
592
+ # @param [String] string a string line containing a prescription site definition
508
593
  #
509
594
  def prescription_site(string)
510
595
  p = Prescription.load(string, @current_parent)
@@ -513,24 +598,23 @@ module RTP
513
598
 
514
599
  # Creates a site setup record from the given string.
515
600
  #
516
- # === Parameters
517
- #
518
- # * <tt>string</tt> -- An single line string from an RTPConnect ascii file.
601
+ # @param [String] string a string line containing a site setup definition
519
602
  #
520
603
  def site_setup(string)
521
604
  s = SiteSetup.load(string, @current_parent)
522
605
  @current_parent = s
523
606
  end
524
607
 
525
- # Returns the attributes of this instance in an array (for comparison purposes).
608
+ # Collects the attributes of this instance.
609
+ #
610
+ # @note The CRC is not considered part of the attributes of interest and is excluded
611
+ # @return [Array<String>] an array of attributes
526
612
  #
527
613
  alias_method :state, :values
528
614
 
529
615
  # Creates a treatment field record from the given string.
530
616
  #
531
- # === Parameters
532
- #
533
- # * <tt>string</tt> -- An single line string from an RTPConnect ascii file.
617
+ # @param [String] string a string line containing a treatment field definition
534
618
  #
535
619
  def treatment_field(string)
536
620
  f = Field.load(string, @current_parent)