Class: Name_phonetic_record

Inherits:
GEDCOMBase show all
Defined in:
lib/gedcom/name_phonetic_record.rb

Overview

GEDCOM 5.5.1 Draft adds as subordinate to NAME

+1 FONE <NAME_PHONETIC_VARIATION> +2 TYPE <PHONETIC_TYPE> +2 <<PERSONAL_NAME_PIECES>>

==NAME_PHONETIC_VARIATION:= Size=1:120 PHONETIC_TYPE [<user defined> | hangul | kana] Size=5:30 The phonetic variation of the name is written in the same form as the was the name used in the superior <NAME_PERSONAL> primitive, but phonetically written using the method indicated by the subordinate <PHONETIC_TYPE> value, for example if hiragana was used to provide a reading of a name written in kanji, then the <PHONETIC_TYPE> value would indicate 'kana'.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GEDCOMBase

#changed, #changed?, #created?, #find, #locked?, no_tabs, #private?, #save, tabs, #to_db, #to_gedcom, #to_s, #to_s_ordered, #to_s_r, #token_to_s, #xref_check

Constructor Details

#initialize(*a) ⇒ Name_phonetic_record

Returns a new instance of Name_phonetic_record.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gedcom/name_phonetic_record.rb', line 23

def initialize(*a)
  super(*a)
   @this_level = [ [:print, "FONE", :phonetic_name] ]
   @sub_level = [
                     [:print, "NPFX",    :prefix ],
                     [:print, "GIVN",    :given ],
                     [:print, "NICK",    :nickname ],
                     [:print, "SPFX",    :surname_prefix ],
                     [:print, "SURN",    :surname ],
                     [:print, "NSFX",    :suffix ],
                     [:walk, nil,    :source_citation_record],
                     [:walk, nil,    :note_citation_record],
                     [:print, "RESN", :restriction],
                 ] 
end

Instance Attribute Details

#givenObject

Returns the value of attribute given.



19
20
21
# File 'lib/gedcom/name_phonetic_record.rb', line 19

def given
  @given
end

#nicknameObject

Returns the value of attribute nickname.



19
20
21
# File 'lib/gedcom/name_phonetic_record.rb', line 19

def nickname
  @nickname
end

#note_citation_recordObject

Returns the value of attribute note_citation_record.



20
21
22
# File 'lib/gedcom/name_phonetic_record.rb', line 20

def note_citation_record
  @note_citation_record
end

#phonetic_name=(value) ⇒ Object (writeonly)

Phonetic Name is stored in phonetic_name and recovered via def name, or the alias phonetic_name



18
19
20
# File 'lib/gedcom/name_phonetic_record.rb', line 18

def phonetic_name=(value)
  @phonetic_name = value
end

#prefixObject

Returns the value of attribute prefix.



19
20
21
# File 'lib/gedcom/name_phonetic_record.rb', line 19

def prefix
  @prefix
end

#restrictionObject

Returns the value of attribute restriction.



20
21
22
# File 'lib/gedcom/name_phonetic_record.rb', line 20

def restriction
  @restriction
end

#source_citation_recordObject

Returns the value of attribute source_citation_record.



20
21
22
# File 'lib/gedcom/name_phonetic_record.rb', line 20

def source_citation_record
  @source_citation_record
end

#suffixObject

Returns the value of attribute suffix.



19
20
21
# File 'lib/gedcom/name_phonetic_record.rb', line 19

def suffix
  @suffix
end

#surnameObject

Returns the value of attribute surname.



19
20
21
# File 'lib/gedcom/name_phonetic_record.rb', line 19

def surname
  @surname
end

#surname_prefixObject

Returns the value of attribute surname_prefix.



19
20
21
# File 'lib/gedcom/name_phonetic_record.rb', line 19

def surname_prefix
  @surname_prefix
end

Instance Method Details

#nameObject Also known as: phonetic_name

return the name as a string. It might be returned be the #phonetic_name method. or it might need to be contructed from the Name_phonetic_record personal name pieces attributes.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gedcom/name_phonetic_record.rb', line 41

def name
  if (name = phonetic_name) == nil
    name = "" #could be what we return if none of the Name_record attributes are set
    if @prefix
      name += @prefix.first
      name += ' ' if @given || @nickname || @surname_prefix || @surname || @suffix
    end
    if @given
      name += @given.first  
      name += ' ' if  @nickname || @surname_prefix || @surname || @suffix
    end
    if @nickname
      name += '(' + @nickname.first + ')'  
      name += ' ' if @surname_prefix || @surname || @suffix
    end
    if @surname_prefix
      name += @surname_prefix.first
      name += ' ' if  @surname || @suffix
    end
    if @surname
      name += ( '/' + @surname.first + '/' ) 
      name += ' ' if  @suffix
    end
    name += @suffix.first  if @suffix
  end
  return name.first
end