Class: Gedcomx::Relationship

Inherits:
Object
  • Object
show all
Defined in:
lib/gedcomx/relationship.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = nil) ⇒ Relationship

Returns a new instance of Relationship.



18
19
20
21
22
# File 'lib/gedcomx/relationship.rb', line 18

def initialize(input = nil)
  @relationship = input || self.class.java_class.new
  @person1 = Gedcomx::ResourceReference.new(@relationship.get_person1) if @relationship.get_person1
  @person2 = Gedcomx::ResourceReference.new(@relationship.get_person2) if @relationship.get_person2
end

Instance Attribute Details

#person1Object

Returns the value of attribute person1.



4
5
6
# File 'lib/gedcomx/relationship.rb', line 4

def person1
  @person1
end

#person2Object

Returns the value of attribute person2.



4
5
6
# File 'lib/gedcomx/relationship.rb', line 4

def person2
  @person2
end

Class Method Details

.create(attributes = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/gedcomx/relationship.rb', line 10

def self.create(attributes = {})
  new_relationship = self.new
  new_relationship.type = attributes[:type] if attributes[:type]
  new_relationship.person1 = attributes[:person1] if attributes[:person1]
  new_relationship.person2 = attributes[:person2] if attributes[:person2]
  new_relationship
end

.java_classObject



6
7
8
# File 'lib/gedcomx/relationship.rb', line 6

def self.java_class
  Java::OrgGedcomxConclusion::Relationship
end

Instance Method Details

#couple?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gedcomx/relationship.rb', line 24

def couple?
  type == TYPES[:couple]
end

#parent_child?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/gedcomx/relationship.rb', line 28

def parent_child?
  type == TYPES[:parent_child]
end

#to_javaObject



52
53
54
# File 'lib/gedcomx/relationship.rb', line 52

def to_java
  @relationship
end

#typeObject



44
45
46
# File 'lib/gedcomx/relationship.rb', line 44

def type
  @relationship.get_type.to_s
end

#type=(input_type) ⇒ Object



48
49
50
# File 'lib/gedcomx/relationship.rb', line 48

def type=(input_type)
  @relationship.type = ( input_type.is_a? Gedcomx.java_uri_class ) ? input_type : Gedcomx.new_uri(input_type)
end