Class: Riddl::Wrapper::Declaration::Facade

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/riddl/wrapper/declaration/facade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFacade

Returns a new instance of Facade.



8
9
10
# File 'lib/ruby/riddl/wrapper/declaration/facade.rb', line 8

def initialize
  @resource = Riddl::Wrapper::Description::Resource.new("/")
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



6
7
8
# File 'lib/ruby/riddl/wrapper/declaration/facade.rb', line 6

def resource
  @resource
end

Instance Method Details

#description_xml(namespaces) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ruby/riddl/wrapper/declaration/facade.rb', line 12

def description_xml(namespaces)
  #{{{
  namespaces = namespaces.delete_if do |k,n|
    k =~ /^xmlns\d+$/ || [Riddl::Wrapper::DESCRIPTION, Riddl::Wrapper::DECLARATION, Riddl::Wrapper::XINCLUDE].include?(n)
  end.map do |k,n|
    "xmlns:#{k}=\"#{n}\""
  end.join(' ')

  result = ""
  messages = {}
  names = []
  messages_result = ""
  description_result = ""
  description_xml_priv(result,messages,0)

  result = XML::Smart.string(result)
  messages.each do |hash,mess|
    t = mess.content.dup
    name = mess.name
    name += '_' while names.include?(name)
    result.find("//@*[.=#{hash}]").each { |e| e.value = name }
    names << name
    t.root.attributes['name'] = name
    messages_result << t.root.dump + "\n"
  end
  XML::Smart.string("<description #{Riddl::Wrapper::COMMON} #{namespaces}>\n\n" + description_result + messages_result.gsub(/^/,'  ') + "\n" + result.root.dump + "\n</description>").to_s
  #}}}
end

#merge_tiles(res, fac = @resource) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ruby/riddl/wrapper/declaration/facade.rb', line 54

def merge_tiles(res,fac=@resource)
  #{{{
  fac.custom = fac.custom + res.custom
  res.composition.each do |method,s|
    fac.composition[method] ||= []
    fac.composition[method] += s
  end
  res.resources.each do |path,r|
    if !fac.resources.has_key?(path)
      fac.resources[path] = Riddl::Wrapper::Description::Resource.new(path,r.recursive)
    end
    merge_tiles(r,fac.resources[path])
  end
  #}}}
end