Class: Gedcomx::Fact

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input = nil) ⇒ Fact

Returns a new instance of Fact.



20
21
22
23
24
25
26
# File 'lib/gedcomx/fact.rb', line 20

def initialize(input = nil)
  @fact = input || self.class.java_class.new
  @date = Gedcomx::Date.new(@fact.get_date) if @fact.get_date
  @place = Gedcomx::Place.new(@fact.get_place) if @fact.get_place
  @fields = []
  @fields = @fact.fields.map { |field| Gedcomx::Field.new(field) } if @fact.fields.is_a? Array
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#fieldsObject (readonly)

Returns the value of attribute fields.



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

def fields
  @fields
end

#placeObject (readonly)

Returns the value of attribute place.



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

def place
  @place
end

Class Method Details

.create(attributes = {}) ⇒ Object



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

def self.create(attributes = {})
  new_fact = self.new
  new_fact.date = attributes[:date] if attributes[:date]
  new_fact.type = attributes[:type] if attributes[:type]
  new_fact.value = attributes[:value] if attributes[:value]
  new_fact.primary = attributes[:primary] if attributes[:primary]
  attributes[:fields].each { |field| new_fact.add_field(field) } if attributes[:fields].is_a? Array
  new_fact
end

.java_classObject



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

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

Instance Method Details

#add_field(field) ⇒ Object



28
29
30
31
32
# File 'lib/gedcomx/fact.rb', line 28

def add_field(field)
  return false unless field.is_a? Gedcomx::Field
  @fact.add_field field.to_java
  @fact.fields << field
end

#primary=(is_primary) ⇒ Object



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

def primary=(is_primary)
  return false unless is_primary.is_a? Boolean
  @fact.primary = is_primary
end

#primary?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/gedcomx/fact.rb', line 40

def primary?
  @fact.get_primary
end

#to_javaObject



65
66
67
# File 'lib/gedcomx/fact.rb', line 65

def to_java
  @fact
end

#typeObject



49
50
51
# File 'lib/gedcomx/fact.rb', line 49

def type
  @fact.get_type.to_s
end

#type=(input_type) ⇒ Object



53
54
55
# File 'lib/gedcomx/fact.rb', line 53

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

#valueObject



57
58
59
# File 'lib/gedcomx/fact.rb', line 57

def value
  @fact.get_value
end

#value=(value_string) ⇒ Object



61
62
63
# File 'lib/gedcomx/fact.rb', line 61

def value= (value_string)
  @fact.value = value_string
end