Class: RTP::ExtendedPlan

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

Overview

Note:

Relations:

  • Parent: Plan

  • Children: none

The Extended plan class.

Constant Summary

Constants inherited from Record

Record::NR_SURPLUS_ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from Record

#attributes, #crc, #keyword

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#encode, #get_parent, #load, #to_record, #to_s, #values

Constructor Details

#initialize(parent) ⇒ ExtendedPlan

Creates a new ExtendedPlan.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rtp-connect/extended_plan.rb', line 33

def initialize(parent)
  super('EXTENDED_PLAN_DEF', 4, 5)
  # Parent relation (may get more than one type of record here):
  @parent = get_parent(parent.to_record, Plan)
  @parent.add_extended_plan(self)
  @attributes = [
    # Required:
    :keyword,
    :encoding,
    :fullname,
    # Optional:
    :patient_comments
  ]
end

Instance Attribute Details

#encodingObject

Returns the value of attribute encoding.



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

def encoding
  @encoding
end

#fullnameObject

Returns the value of attribute fullname.



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

def fullname
  @fullname
end

#parentObject

The Record which this instance belongs to.



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

def parent
  @parent
end

#patient_commentsObject

Returns the value of attribute patient_comments.



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

def patient_comments
  @patient_comments
end

Class Method Details

.load(string, parent) ⇒ ExtendedPlan

Creates a new ExtendedPlan by parsing a RTPConnect string line.

Raises:

  • (ArgumentError)

    if given a string containing an invalid number of elements



24
25
26
27
# File 'lib/rtp-connect/extended_plan.rb', line 24

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



56
57
58
59
60
# File 'lib/rtp-connect/extended_plan.rb', line 56

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

#childrenArray

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



68
69
70
# File 'lib/rtp-connect/extended_plan.rb', line 68

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.



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

def hash
  state.hash
end

#to_extended_planExtendedPlan

Returns self.



86
87
88
# File 'lib/rtp-connect/extended_plan.rb', line 86

def to_extended_plan
  self
end