Class: RTP::ExtendedPlan
- Defined in:
- lib/rtp-connect/extended_plan.rb
Overview
Relations:
-
Parent: Plan
-
Children: none
The Extended plan class.
Instance Attribute Summary collapse
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#fullname ⇒ Object
Returns the value of attribute fullname.
-
#parent ⇒ Object
readonly
The Record which this instance belongs to.
Attributes inherited from Record
Class Method Summary collapse
-
.load(string, parent) ⇒ ExtendedPlan
Creates a new ExtendedPlan by parsing a RTPConnect string line.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Checks for equality.
-
#children ⇒ Array
Gives an empty array, as these instances are child-less by definition.
-
#hash ⇒ Fixnum
Computes a hash code for this object.
-
#initialize(parent) ⇒ ExtendedPlan
constructor
Creates a new ExtendedPlan.
-
#to_extended_plan ⇒ ExtendedPlan
Returns self.
-
#to_s ⇒ String
(also: #to_str)
Encodes the ExtendedPlan object + any hiearchy of child objects, to a properly formatted RTPConnect ascii string.
Methods inherited from Record
#encode, #get_parent, #load, #to_record, #values
Constructor Details
#initialize(parent) ⇒ ExtendedPlan
Creates a new ExtendedPlan.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rtp-connect/extended_plan.rb', line 32 def initialize(parent) super('EXTENDED_PLAN_DEF', 4, 4) # 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 ] end |
Instance Attribute Details
#encoding ⇒ Object
Returns the value of attribute encoding.
13 14 15 |
# File 'lib/rtp-connect/extended_plan.rb', line 13 def encoding @encoding end |
#fullname ⇒ Object
Returns the value of attribute fullname.
14 15 16 |
# File 'lib/rtp-connect/extended_plan.rb', line 14 def fullname @fullname end |
#parent ⇒ Object (readonly)
The Record which this instance belongs to.
12 13 14 |
# File 'lib/rtp-connect/extended_plan.rb', line 12 def parent @parent end |
Class Method Details
.load(string, parent) ⇒ ExtendedPlan
Creates a new ExtendedPlan by parsing a RTPConnect string line.
23 24 25 26 |
# File 'lib/rtp-connect/extended_plan.rb', line 23 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.
53 54 55 56 57 |
# File 'lib/rtp-connect/extended_plan.rb', line 53 def ==(other) if other.respond_to?(:to_extended_plan) other.send(:state) == state end end |
#children ⇒ Array
Gives an empty array, as these instances are child-less by definition.
65 66 67 |
# File 'lib/rtp-connect/extended_plan.rb', line 65 def children return Array.new end |
#hash ⇒ Fixnum
Two objects with the same attributes will have the same hash code.
Computes a hash code for this object.
75 76 77 |
# File 'lib/rtp-connect/extended_plan.rb', line 75 def hash state.hash end |
#to_extended_plan ⇒ ExtendedPlan
Returns self.
83 84 85 |
# File 'lib/rtp-connect/extended_plan.rb', line 83 def to_extended_plan self end |
#to_s ⇒ String Also known as: to_str
Encodes the ExtendedPlan object + any hiearchy of child objects, to a properly formatted RTPConnect ascii string.
92 93 94 95 96 97 98 99 100 |
# File 'lib/rtp-connect/extended_plan.rb', line 92 def to_s str = encode if children children.each do |child| str += child.to_s end end return str end |