Class: Org::Familysearch::Ws::Familytree::V2::Schema::PersonRelationships

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-fs-stack/enunciate/familytree.rb,
lib/ruby-fs-stack/familytree/relationship.rb

Overview

A FamilyTree person relationships section.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePersonRelationships

Returns a new instance of PersonRelationships.



116
117
118
119
120
# File 'lib/ruby-fs-stack/familytree/relationship.rb', line 116

def initialize
  @parents = []
  @spouses = []
  @children = []
end

Instance Attribute Details

#childrenObject

A collection of parent relationships for this person.



1401
1402
1403
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1401

def children
  @children
end

#parentsObject

A collection of parent relationships for this person.



1397
1398
1399
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1397

def parents
  @parents
end

#spousesObject

A collection of spouse relationships for this person.



1399
1400
1401
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1399

def spouses
  @spouses
end

Class Method Details

.from_json(o) ⇒ Object

constructs a PersonRelationships from a (parsed) JSON hash



1449
1450
1451
1452
1453
1454
1455
1456
1457
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1449

def self.from_json(o)
  if o.nil?
    return nil
  else
    inst = new
    inst.init_jaxb_json_hash o
    return inst
  end
end

Instance Method Details

#add_relationship(options) ⇒ Object

Params

  • options - requires the following:

** :type - ‘parent’, ‘child’, ‘spouse’ ** :with - ID of the person with whom you are making the relationship ** :lineage (optional) - ‘Biological’, ‘Adoptive’, etc. ** :event - a hash with values => ‘Marriage’, :date => ‘15 Nov 2007’, :place => ‘Utah, United States’ ** :ordinance - a hash with values => ‘15 Nov 2007’, :temple => ‘SLAKE’, :place => ‘Utah, United States’, :type => “Sealing_to_Spouse”



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/ruby-fs-stack/familytree/relationship.rb', line 129

def add_relationship(options)
  relationship = self.get_relationships_of_type(options[:type]).find{|r|r.id == options[:with] || r.requestedId == options[:with]}
  if relationship.nil?
    relationship = Relationship.new
    relationship.id = options[:with]
  end
  if options[:lineage]
    relationship.add_lineage_characteristic(options[:lineage]) if options[:lineage]
  else
    relationship.add_exists
  end
  if options[:event]
    relationship.add_event(options[:event])
  end
  if options[:ordinance]
    relationship.add_ordinance(options[:ordinance])
  end
  s_command = set_command(options[:type])
  self.send(s_command.to_sym,[relationship])
end

#get_relationships_of_type(type) ⇒ Object

Params

  • type - should be ‘child’, ‘spouse’, or ‘parent’



152
153
154
155
# File 'lib/ruby-fs-stack/familytree/relationship.rb', line 152

def get_relationships_of_type(type)
  g_command = get_command(type)
  relationships = self.send(g_command.to_sym)
end

#init_jaxb_json_hash(_o) ⇒ Object

initializes this PersonRelationships with a json hash



1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1430

def init_jaxb_json_hash(_o)
  if !_o['parent'].nil?
    @parents = Array.new
    _oa = _o['parent']
    _oa.each { | _item | @parents.push Org::Familysearch::Ws::Familytree::V2::Schema::Relationship.from_json(_item) }
  end
  if !_o['spouse'].nil?
    @spouses = Array.new
    _oa = _o['spouse']
    _oa.each { | _item | @spouses.push Org::Familysearch::Ws::Familytree::V2::Schema::Relationship.from_json(_item) }
  end
  if !_o['child'].nil?
    @children = Array.new
    _oa = _o['child']
    _oa.each { | _item | @children.push Org::Familysearch::Ws::Familytree::V2::Schema::Relationship.from_json(_item) }
  end
end

#to_jaxb_json_hashObject

the json hash for this PersonRelationships



1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1404

def to_jaxb_json_hash
  _h = {}
  if !parents.nil?
    _ha = Array.new
    parents.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['parent'] = _ha
  end
  if !spouses.nil?
    _ha = Array.new
    spouses.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['spouse'] = _ha
  end
  if !children.nil?
    _ha = Array.new
    children.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['child'] = _ha
  end
  return _h
end

#to_jsonObject

the json (string form) for this PersonRelationships



1425
1426
1427
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 1425

def to_json
  to_jaxb_json_hash.to_json
end