Class: RelatonBib::BibItemLocality

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/bib_item_locality.rb

Overview

Bibliographic item locality.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, reference_from, reference_to = nil) ⇒ BibItemLocality

Returns a new instance of BibItemLocality.

Parameters:

  • type (String)
  • referenceFrom (String)
  • referenceTo (String, NilClass)


32
33
34
35
36
# File 'lib/relaton_bib/bib_item_locality.rb', line 32

def initialize(type, reference_from, reference_to = nil)
  @type           = type
  @reference_from = reference_from
  @reference_to   = reference_to
end

Instance Attribute Details

#reference_fromString (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/relaton_bib/bib_item_locality.rb', line 24

def reference_from
  @reference_from
end

#reference_toString, NilClass (readonly)

Returns:

  • (String, NilClass)


27
28
29
# File 'lib/relaton_bib/bib_item_locality.rb', line 27

def reference_to
  @reference_to
end

#typeString (readonly)

Returns:

  • (String)


21
22
23
# File 'lib/relaton_bib/bib_item_locality.rb', line 21

def type
  @type
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


46
47
48
49
50
# File 'lib/relaton_bib/bib_item_locality.rb', line 46

def to_hash
  hash = { "type" => type, "reference_from" => reference_from }
  hash["reference_to"] = reference_to if reference_to
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


39
40
41
42
43
# File 'lib/relaton_bib/bib_item_locality.rb', line 39

def to_xml(builder)
  builder.parent[:type] = type
  builder.referenceFrom reference_from # { reference_from.to_xml(builder) }
  builder.referenceTo reference_to if reference_to
end