class Label

Attributes

f[R]

Public Class Methods

new(mod) click to toggle source
# File lib/bud/labeling/labeling.rb, line 207
def initialize(mod)
  @report = nil
  @mod = Object.const_get(mod)
  if @mod.class == Class
    nc = new_class_from_class(@mod)
  elsif @mod.class == Module
    nc = new_class(@mod)
  else
    raise "#{mod} neither class nor module"
  end
  @f = nc.new
  @f.tick
end

Public Instance Methods

disjunction(l, r) click to toggle source
# File lib/bud/labeling/labeling.rb, line 246
def disjunction(l, r)
  both = [l, r]
  if both.include? "D"
    "D"
  elsif both.include? "N"
    if both.include? "A"
      return "D"
    else
      return "N"
    end
  elsif both.include? "A"
    return "A"
  else
    return "Bot"
  end
end
internal_tabs() click to toggle source
# File lib/bud/labeling/labeling.rb, line 277
def internal_tabs
  cls = Class.new do
    include Bud
    include MetaMods
  end
  cls.new.tables.keys
end
new_class(mod) click to toggle source
# File lib/bud/labeling/labeling.rb, line 263
def new_class(mod)
  Class.new do
    include Bud
    include MetaMods
    include mod
  end
end
new_class_from_class(cls) click to toggle source
# File lib/bud/labeling/labeling.rb, line 271
def new_class_from_class(cls)
  Class.new(cls) do
    include MetaMods
  end
end
output_report() click to toggle source
# File lib/bud/labeling/labeling.rb, line 225
def output_report
  validate
  rep = {}
  @report.each do |from, to, path, labels, reason, final|
    rep[to] ||= "Bot"
    rep[to] = disjunction(rep[to], final.last)
  end
  rep
end
path_report() click to toggle source
# File lib/bud/labeling/labeling.rb, line 235
def path_report
  validate
  zips = {}
  @report.each do |from, to, path, labels, reason, final|
    zips[to] ||= {}
    zips[to][from] ||= "Bot"
    zips[to][from] = disjunction(zips[to][from], final.last)
  end
  zips
end
validate() click to toggle source
# File lib/bud/labeling/labeling.rb, line 221
def validate
  @report = @f.validate if @report.nil?
end
write_graph(fmt=:pdf) click to toggle source
# File lib/bud/labeling/labeling.rb, line 285
def write_graph(fmt=:pdf)
  f.finish(internal_tabs, "#{@mod.to_s}.#{fmt}", fmt)
end