Class: Gedcomx::NamePart
- Inherits:
-
Object
- Object
- Gedcomx::NamePart
- Defined in:
- lib/gedcomx/name_part.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Class Method Summary collapse
Instance Method Summary collapse
- #add_field(field) ⇒ Object
-
#initialize(input = nil) ⇒ NamePart
constructor
A new instance of NamePart.
- #to_java ⇒ Object
- #type ⇒ Object
- #type=(input_type) ⇒ Object
- #value ⇒ Object
- #value=(input_value) ⇒ Object
Constructor Details
#initialize(input = nil) ⇒ NamePart
Returns a new instance of NamePart.
18 19 20 21 22 |
# File 'lib/gedcomx/name_part.rb', line 18 def initialize(input = nil) @name_part = input || self.class.java_class.new @fields = [] @fields = @name_part.fields.map { |field| Gedcomx::Field.new(field) } if @name_part.fields end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
4 5 6 |
# File 'lib/gedcomx/name_part.rb', line 4 def fields @fields end |
Class Method Details
.create(attributes = {}) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/gedcomx/name_part.rb', line 10 def self.create(attributes = {}) new_part = self.new new_part.value = attributes[:value] if attributes[:value] new_part.type = attributes[:type] if attributes[:type] attributes[:fields].each { |field| new_part.add_field field } if attributes[:fields].is_a? Array new_part end |
.java_class ⇒ Object
6 7 8 |
# File 'lib/gedcomx/name_part.rb', line 6 def self.java_class Java::OrgGedcomxConclusion::NamePart end |
Instance Method Details
#add_field(field) ⇒ Object
24 25 26 27 28 |
# File 'lib/gedcomx/name_part.rb', line 24 def add_field(field) return false unless field.is_a? Gedcomx::Field @name_part.to_java.add_field field.to_java @fields << field end |
#to_java ⇒ Object
46 47 48 |
# File 'lib/gedcomx/name_part.rb', line 46 def to_java @name_part end |
#type ⇒ Object
30 31 32 |
# File 'lib/gedcomx/name_part.rb', line 30 def type @name_part.get_type.to_s end |
#type=(input_type) ⇒ Object
34 35 36 |
# File 'lib/gedcomx/name_part.rb', line 34 def type=(input_type) @name_part.type = ( input_type.is_a? Gedcomx.java_uri_class ) ? input_type : Gedcomx.new_uri(input_type) end |
#value ⇒ Object
38 39 40 |
# File 'lib/gedcomx/name_part.rb', line 38 def value @name_part.get_value end |
#value=(input_value) ⇒ Object
42 43 44 |
# File 'lib/gedcomx/name_part.rb', line 42 def value=(input_value) @name_part.value = input_value end |