Class: Desmoservice::Edition

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEdition

Returns a new instance of Edition.



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

def initialize
  @xml = '<edition>'
end

Class Method Details

.attr(xml, attr_key, values) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/edition.rb', line 85

def self.attr(xml, attr_key, values)
  index = attr_key.index(':')
  ns = attr_key[0,index]
  localkey = attr_key[index+1..-1]
  if values.nil?
    xml << '<attr-remove ns="' << ns << '" key="' << localkey << '"/>'
  else
    xml << '<attr ns="' << ns << '" key="' << localkey << '">'
    if values.is_a? String
      xml << '<val>' << Rack::Utils.escape_html(values) << '</val>'
    else
      values.each do |v|
        xml << '<val>' << Rack::Utils.escape_html(v) << '</val>'
      end
    end
    xml << '</attr>'
  end
end

.family(xml, family_arg) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/edition.rb', line 65

def self.family(xml, family_arg)
  xml << '<famille '
  if family_arg.is_a? Integer
      xml << 'code' << '="' << family_arg.to_s << '"'
  else
      xml << 'idctxt' << '="' << family_arg << '"'
  end
  xml << '/>'
end

.key_prefix(xml, key_prefix_arg) ⇒ Object



104
105
106
107
108
# File 'lib/edition.rb', line 104

def self.key_prefix(xml, key_prefix_arg)
  xml << '<key-prefix>'
  xml << Rack::Utils.escape_html(key_prefix_arg)
  xml << '</key-prefix>'
end

.text(xml, lang, content) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/edition.rb', line 75

def self.text(xml, lang, content)
  if content.nil?
    xml << '<lib-remove xml:lang="' << lang << '"/>'
  else
    xml << '<lib xml:lang="' << lang << '">'
    xml << Rack::Utils.escape_html(content)
    xml << '</lib>'
  end
end

.to_attribute(xml, term_arg, suffix = nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/edition.rb', line 47

def self.to_attribute(xml, term_arg, suffix=nil)
  if term_arg.is_a? Integer
    xml << ' '
    if suffix.nil?
      xml << 'code' << '="' << term_arg.to_s << '"'
    else
      xml << suffix << '="' << term_arg.to_s << '"'
    end
  elsif not term_arg.nil?
    xml << ' '
    if suffix.nil?
      xml << 'iddesc' << '="' << term_arg.to_s << '"'
    else
      xml << suffix << '-iddesc="' << term_arg.to_s << '"'
    end
  end
end

Instance Method Details

#change_term(term_arg) {|TermEdit.new(@xml)| ... } ⇒ Object

Yields:



33
34
35
36
37
38
39
# File 'lib/edition.rb', line 33

def change_term(term_arg)
  @xml << '<term-change'
  Edition.to_attribute(@xml, term_arg)
  @xml << '>'
  yield(TermEdit.new(@xml))
  @xml << '</term-change>'
end

#close_to_xmlObject



10
11
12
13
# File 'lib/edition.rb', line 10

def close_to_xml
  @xml << '</edition>'
  return @xml
end

#create_ligature(inferior_arg = nil) {|LigatureEdit.new(@xml)| ... } ⇒ Object

arg peut être un entier (id) ou une chaine (localkey)

Yields:



16
17
18
19
20
21
22
# File 'lib/edition.rb', line 16

def create_ligature(inferior_arg=nil)
  @xml << '<lienhierarchique-creation'
  Edition.to_attribute(@xml, inferior_arg, 'fils')
  @xml << '>'
  yield(LigatureEdit.new(@xml))
  @xml << '</lienhierarchique-creation>'
end

#remove_ligature(inferior_arg = nil) {|LigatureEdit.new(@xml)| ... } ⇒ Object

arg peut être un entier (id) ou une chaine (localkey)

Yields:



25
26
27
28
29
30
31
# File 'lib/edition.rb', line 25

def remove_ligature(inferior_arg=nil)
  @xml << '<lienhierarchique-remove'
  Edition.to_attribute(@xml, inferior_arg, 'fils')
  @xml << '>'
  yield(LigatureEdit.new(@xml))
  @xml << '</lienhierarchique-remove>'
end

#remove_term(term_arg) ⇒ Object



41
42
43
44
45
# File 'lib/edition.rb', line 41

def remove_term(term_arg)
  @xml << '<term-remove'
  Edition.to_attribute(@xml, term_arg)
  @xml << '/>'
end