Class: RTP::ExtendedField

Inherits:
Record
  • Object
show all
Defined in:
lib/rtp-connect/extended_field.rb

Overview

Note:

Relations:

  • Parent: Field

  • Children: none

The ExtendedField 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, #values

Constructor Details

#initialize(parent) ⇒ ExtendedField

Creates a new (treatment) ExtendedField.

Parameters:

  • parent (Record)

    a record which is used to determine the proper parent of this instance



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rtp-connect/extended_field.rb', line 38

def initialize(parent)
  super('EXTENDED_FIELD_DEF', 4, 10)
  # Parent relation (may get more than one type of record here):

  @parent = get_parent(parent.to_record, Field)
  @parent.add_extended_field(self)
  @attributes = [
    # Required:

    :keyword,
    :field_id,
    :original_plan_uid,
    # Optional:

    :original_beam_number,
    :original_beam_name,
    :is_fff,
    :accessory_code,
    :accessory_type,
    :high_dose_authorization
  ]
end

Instance Attribute Details

#accessory_codeObject

Returns the value of attribute accessory_code.



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

def accessory_code
  @accessory_code
end

#accessory_typeObject

Returns the value of attribute accessory_type.



19
20
21
# File 'lib/rtp-connect/extended_field.rb', line 19

def accessory_type
  @accessory_type
end

#field_idObject

Returns the value of attribute field_id.



13
14
15
# File 'lib/rtp-connect/extended_field.rb', line 13

def field_id
  @field_id
end

#high_dose_authorizationObject

Returns the value of attribute high_dose_authorization.



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

def high_dose_authorization
  @high_dose_authorization
end

#is_fffObject

Returns the value of attribute is_fff.



17
18
19
# File 'lib/rtp-connect/extended_field.rb', line 17

def is_fff
  @is_fff
end

#original_beam_nameObject

Returns the value of attribute original_beam_name.



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

def original_beam_name
  @original_beam_name
end

#original_beam_numberObject

Returns the value of attribute original_beam_number.



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

def original_beam_number
  @original_beam_number
end

#original_plan_uidObject

Returns the value of attribute original_plan_uid.



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

def original_plan_uid
  @original_plan_uid
end

#parentObject (readonly)

The Record which this instance belongs to.



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

def parent
  @parent
end

Class Method Details

.load(string, parent) ⇒ ExtendedField

Creates a new (treatment) ExtendedField by parsing a RTPConnect string line.

Parameters:

  • string (#to_s)

    the extended treatment field 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



29
30
31
32
# File 'lib/rtp-connect/extended_field.rb', line 29

def self.load(string, parent)
  ef = self.new(parent)
  ef.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



66
67
68
69
70
# File 'lib/rtp-connect/extended_field.rb', line 66

def ==(other)
  if other.respond_to?(:to_extended_field)
    other.send(:state) == state
  end
end

#childrenArray

Gives an empty array, as these instances are child-less by definition.

Returns:

  • (Array)

    an emtpy array



78
79
80
# File 'lib/rtp-connect/extended_field.rb', line 78

def children
  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



88
89
90
# File 'lib/rtp-connect/extended_field.rb', line 88

def hash
  state.hash
end

#to_extended_fieldExtendedField

Returns self.

Returns:



96
97
98
# File 'lib/rtp-connect/extended_field.rb', line 96

def to_extended_field
  self
end

#to_sString Also known as: to_str

Encodes the ExtendedField 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



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

def to_s
  str = encode
  if children
    children.each do |child|
      str += child.to_s
    end
  end
  return str
end