Class: Gedcomx::NameForm
- Inherits:
-
Object
- Object
- Gedcomx::NameForm
- Defined in:
- lib/gedcomx/name_form.rb
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
Class Method Summary collapse
Instance Method Summary collapse
- #add_part(part) ⇒ Object
- #full_text ⇒ Object
- #full_text=(full_text) ⇒ Object
-
#initialize(input = nil) ⇒ NameForm
constructor
A new instance of NameForm.
- #to_java ⇒ Object
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
#parts ⇒ Object (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_class ⇒ Object
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_text ⇒ Object
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_java ⇒ Object
37 38 39 |
# File 'lib/gedcomx/name_form.rb', line 37 def to_java @name_form end |