Class: Gedcomx::NameForm

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = nil) ⇒ NameForm

Returns a new instance of NameForm.



17
18
19
20
21
# File 'lib/gedcomx/name_form.rb', line 17

def initialize(input = nil)
  @name_form = input || self.class.java_class.new
  @parts = []
  @parts = @name_form.parts.map { |part| Gedcomx::NamePart.new(part) } if @name_form.parts
end

Instance Attribute Details

#partsObject (readonly)

Returns the value of attribute parts.



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

def parts
  @parts
end

Class Method Details

.create(attributes = {}) ⇒ Object



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

def self.create(attributes = {})
  new_form = self.new
  new_form.full_text = attributes[:full_text] if attributes[:full_text]
  attributes[:fields].each { |field| new_form.add_field field } if attributes[:fields].is_a? Array
  attributes[:parts].each { |part| new_form.add_part part } if attributes[:parts].is_a? Array
end

.java_classObject



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

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

Instance Method Details

#add_part(part) ⇒ Object



23
24
25
26
27
# File 'lib/gedcomx/name_form.rb', line 23

def add_part(part)
  return false unless part.is_a? Gedcomx::NamePart
  @name_form.add_part part.to_java
  @parts << part
end

#full_textObject



29
30
31
# File 'lib/gedcomx/name_form.rb', line 29

def full_text
  @name_form.get_full_text
end

#full_text=(full_text) ⇒ Object



33
34
35
# File 'lib/gedcomx/name_form.rb', line 33

def full_text=(full_text)
  @name_form.full_text = full_text
end

#to_javaObject



37
38
39
# File 'lib/gedcomx/name_form.rb', line 37

def to_java
  @name_form
end