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

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

Overview

A Family Tree person.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePedigree

Returns a new instance of Pedigree.



34
35
36
37
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 34

def initialize
  @person_hash = {}
  @persons = []
end

Instance Attribute Details

#idObject

The id of the person.



3301
3302
3303
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3301

def id
  @id
end

#person_hashObject

Returns the value of attribute person_hash.



32
33
34
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 32

def person_hash
  @person_hash
end

#personsObject

The persons.



3305
3306
3307
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3305

def persons
  @persons
end

#requestedIdObject

The id of the person.



3303
3304
3305
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3303

def requestedId
  @requestedId
end

Class Method Details

.from_json(o) ⇒ Object

constructs a Pedigree from a (parsed) JSON hash



3337
3338
3339
3340
3341
3342
3343
3344
3345
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3337

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

#<<(person) ⇒ Object



45
46
47
48
49
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 45

def <<(person)
  p = PedigreePerson.new(self, person)
  @persons << p
  @person_hash[p.id] = p
end

#continue_idsObject



61
62
63
64
65
66
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 61

def continue_ids
  cns = continue_nodes
  father_ids = cns.select{|n|!n.father_id.nil?}.collect{|n|n.father_id}
  mother_ids = cns.select{|n|!n.mother_id.nil?}.collect{|n|n.mother_id}
  father_ids + mother_ids
end

#continue_node_idsObject



57
58
59
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 57

def continue_node_ids
  continue_nodes.collect{|n|n.id}
end

#continue_nodesObject



51
52
53
54
55
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 51

def continue_nodes
  @persons.select do |person| 
    (!person.mother_id.nil? && person.mother.nil?) || (!person.father_id.nil? && person.father.nil?)
  end
end

#get_person(id) ⇒ Object



68
69
70
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 68

def get_person(id)
  @person_hash[id]
end

#init_jaxb_json_hash(_o) ⇒ Object

initializes this Pedigree with a json hash



3326
3327
3328
3329
3330
3331
3332
3333
3334
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3326

def init_jaxb_json_hash(_o)
  @id = String.from_json(_o['id']) unless _o['id'].nil?
  @requestedId = String.from_json(_o['requestedId']) unless _o['requestedId'].nil?
  if !_o['persons'].nil?
    @persons = Array.new
    _oa = _o['persons']
    _oa.each { | _item | @persons.push Org::Familysearch::Ws::Familytree::V2::Schema::Person.from_json(_item) }
  end
end

#injest(pedigree) ⇒ Object



39
40
41
42
43
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 39

def injest(pedigree)
  @person_hash.merge!(pedigree.person_hash)
  graft_persons_to_self(pedigree.persons)
  @persons = @persons + pedigree.persons
end

#person_idsObject



72
73
74
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 72

def person_ids
  @persons.collect{|p|p.id}
end

#rootObject



91
92
93
# File 'lib/ruby-fs-stack/familytree/pedigree.rb', line 91

def root
  persons.first
end

#to_jaxb_json_hashObject

the json hash for this Pedigree



3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3308

def to_jaxb_json_hash
  _h = {}
  _h['id'] = id.to_jaxb_json_hash unless id.nil?
  _h['requestedId'] = requestedId.to_jaxb_json_hash unless requestedId.nil?
  if !persons.nil?
    _ha = Array.new
    persons.each { | _item | _ha.push _item.to_jaxb_json_hash }
    _h['persons'] = _ha
  end
  return _h
end

#to_jsonObject

the json (string form) for this Pedigree



3321
3322
3323
# File 'lib/ruby-fs-stack/enunciate/familytree.rb', line 3321

def to_json
  to_jaxb_json_hash.to_json
end