class Desmoservice::Edition

Public Class Methods

attr(xml, attr_key, values) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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
new() click to toggle source
# File lib/edition.rb, line 6
def initialize
  @xml = '<edition>'
end
text(xml, lang, content) click to toggle source
# 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) click to toggle source
# 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

Public Instance Methods

change_term(term_arg) { |term_edit| ... } click to toggle source
# 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_xml() click to toggle source
# File lib/edition.rb, line 10
def close_to_xml
  @xml << '</edition>'
  return @xml
end
create_ligature(inferior_arg=nil) { |ligature_edit| ... } click to toggle source

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

# 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) { |ligature_edit| ... } click to toggle source

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

# 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) click to toggle source
# File lib/edition.rb, line 41
def remove_term(term_arg)
  @xml << '<term-remove'
  Edition.to_attribute(@xml, term_arg)
  @xml << '/>'
end