Class: MoveToGo::ReferenceToSource

Inherits:
Object
  • Object
show all
Includes:
SerializeHelper
Defined in:
lib/move-to-go/model/referencetosource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SerializeHelper

#serialize, #serialize_to_file

Constructor Details

#initialize(opt = nil) ⇒ ReferenceToSource

Returns a new instance of ReferenceToSource.



20
21
22
23
24
25
26
27
# File 'lib/move-to-go/model/referencetosource.rb', line 20

def initialize(opt = nil)
    if opt != nil
        serialize_variables.each do |myattr|
            val = opt[myattr[:id]]
            instance_variable_set("@" + myattr[:id].to_s,val) if val != nil
        end
    end
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



4
5
6
# File 'lib/move-to-go/model/referencetosource.rb', line 4

def format
  @format
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/move-to-go/model/referencetosource.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/move-to-go/model/referencetosource.rb', line 4

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
36
37
38
# File 'lib/move-to-go/model/referencetosource.rb', line 33

def ==(other)
    if other==nil 
        return false
    end
    return @name == other.name && @id == other.id && @format== other.format
end

#ecp_dk(id) ⇒ Object



52
53
54
55
56
# File 'lib/move-to-go/model/referencetosource.rb', line 52

def ecp_dk(id)
    @name = 'edk'
    @format = 'External'
    @id = id
end

#ecp_no(id) ⇒ Object



46
47
48
49
50
# File 'lib/move-to-go/model/referencetosource.rb', line 46

def ecp_no(id)
    @name = 'eno'
    @format = 'External'
    @id = id
end

#get_import_rowsObject



14
15
16
17
18
# File 'lib/move-to-go/model/referencetosource.rb', line 14

def get_import_rows
    (serialize_variables + [{ :id => :value, :type => :string }]).map do |p|
        map_to_row p
    end
end

#par_se(id) ⇒ Object

Sets the id of this instance to the parameter supplied. Will also set #name and #format so that this reference is identified as a PAR identifier by Go.



40
41
42
43
44
# File 'lib/move-to-go/model/referencetosource.rb', line 40

def par_se(id)
    @name = 'pase'
    @format = 'External'
    @id = id
end

#serialize_nameObject



10
11
12
# File 'lib/move-to-go/model/referencetosource.rb', line 10

def serialize_name
    "ReferenceToSource"
end

#serialize_variablesObject



6
7
8
# File 'lib/move-to-go/model/referencetosource.rb', line 6

def serialize_variables
    [:name, :format, :id].map { |prop| { :id => prop, :type => :string } }
end

#to_sObject



29
30
31
# File 'lib/move-to-go/model/referencetosource.rb', line 29

def to_s
    return "#{@name}_#{@format}_#{@id}"
end