Class: Riddl::Wrapper::Declaration::Tile

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTile

{{



7
8
9
10
11
12
# File 'lib/ruby/riddl/wrapper/declaration/tile.rb', line 7

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

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



107
108
109
# File 'lib/ruby/riddl/wrapper/declaration/tile.rb', line 107

def resource
  @resource
end

Instance Method Details

#add_description(des, desres, path, index, interface, block, rec = nil, res = @base_path) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ruby/riddl/wrapper/declaration/tile.rb', line 46

def add_description(des,desres,path,index,interface,block,rec=nil,res=@base_path)
  #{{{
  res = add_path(path,res,rec)
  res.add_access_methods(des,desres,index,interface)
  res.add_custom(desres)
  desres.find("des:resource").each do |tdesres|
    cpath = tdesres.attributes['relative'] || "{}"
    rec = tdesres.attributes['recursive']
    int = Interface.new_from_interface(interface,(interface.sub+"/"+cpath).gsub(/\/+/,'/'))
    add_description(des,tdesres,cpath,index,int,block,rec,res)
  end
  block.each do |bl|
    bpath = bl.to_s.gsub(/\/+/,'/').gsub(/\/$/,'')
    bpath = (bpath == "" ? "/" : bpath)
    if interface.sub == bpath
      res.remove_access_methods(des,bl.attributes,index)
    end
  end
  nil
  #}}}
end

#base_path(path) ⇒ Object



97
98
99
100
101
102
103
104
105
# File 'lib/ruby/riddl/wrapper/declaration/tile.rb', line 97

def base_path(path)
  #{{{
  if path.nil? || path == '/'
    @base_path
  else
    @base_path = add_path(path,@base_path)
  end
  #}}}
end

#compose!(res = @base_path) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ruby/riddl/wrapper/declaration/tile.rb', line 68

def compose!(res=@base_path)
  #{{{
  # delete empty resources
  # THIS is a stupid idea, just not show it in the resulting xml! TODO
  # res.resources.delete_if do |k,r|
  #   r.access_methods.length == 0
  # end
  # compose
  res.compose!
  res.resources.each do |k,r|
    compose!(r)
  end
  #}}}
end

#visualize(mode, res = @resource, what = '') ⇒ Object



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
40
41
42
43
44
# File 'lib/ruby/riddl/wrapper/declaration/tile.rb', line 14

def visualize(mode,res=@resource,what='')
  #{{{
  what += res.path
  puts what
  if mode == :layers
    res.access_methods.each do |k,v|
      puts "  #{k.to_s.upcase}:"
      v.each_with_index do |l,i|
        puts "    Layer #{i}:"
        l.each do |r|
          puts "      #{r.class.name.gsub(/[^\:]+::/,'')}: #{r.visualize}"
        end unless l.nil?
      end
    end
  end
  if mode == :composition
    res.composition.each do |k,v|
      puts "  #{k.to_s.upcase}:"
      v.each do |r|
        puts "    #{r.result.class.name.gsub(/[^\:]+::/,'')}: #{r.result.visualize}"
        r.route.each do |ritem|
          puts "      #{ritem.class.name.gsub(/[^\:]+::/,'')}: #{ritem.visualize}"
        end unless r.route.nil?
      end
    end
  end
  res.resources.each do |key,r|
    visualize(mode,r,what + (what == '/' ? ''  : '/'))
  end
  #}}}
end