Class: Gedcomx::Fact
- Inherits:
-
Object
- Object
- Gedcomx::Fact
- Defined in:
- lib/gedcomx/fact.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#place ⇒ Object
readonly
Returns the value of attribute place.
Class Method Summary collapse
Instance Method Summary collapse
- #add_field(field) ⇒ Object
-
#initialize(input = nil) ⇒ Fact
constructor
A new instance of Fact.
- #primary=(is_primary) ⇒ Object
- #primary? ⇒ Boolean
- #to_java ⇒ Object
- #type ⇒ Object
- #type=(input_type) ⇒ Object
- #value ⇒ Object
- #value=(value_string) ⇒ Object
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
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/gedcomx/fact.rb', line 4 def date @date end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
4 5 6 |
# File 'lib/gedcomx/fact.rb', line 4 def fields @fields end |
#place ⇒ Object (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_class ⇒ Object
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
40 41 42 |
# File 'lib/gedcomx/fact.rb', line 40 def primary? @fact.get_primary end |
#to_java ⇒ Object
65 66 67 |
# File 'lib/gedcomx/fact.rb', line 65 def to_java @fact end |
#type ⇒ Object
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 |
#value ⇒ Object
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 |