Class: Label
- Inherits:
-
Object
- Object
- Label
- Defined in:
- lib/bud/labeling/labeling.rb
Instance Attribute Summary collapse
-
#f ⇒ Object
readonly
Returns the value of attribute f.
Instance Method Summary collapse
- #disjunction(l, r) ⇒ Object
-
#initialize(mod) ⇒ Label
constructor
A new instance of Label.
- #internal_tabs ⇒ Object
- #new_class(mod) ⇒ Object
- #new_class_from_class(cls) ⇒ Object
- #output_report ⇒ Object
- #path_report ⇒ Object
- #validate ⇒ Object
- #write_graph(fmt = :pdf) ⇒ Object
Constructor Details
#initialize(mod) ⇒ Label
Returns a new instance of Label.
207 208 209 210 211 212 213 214 215 216 217 218 219 |
# 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 |
Instance Attribute Details
#f ⇒ Object (readonly)
Returns the value of attribute f.
205 206 207 |
# File 'lib/bud/labeling/labeling.rb', line 205 def f @f end |
Instance Method Details
#disjunction(l, r) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# 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 ⇒ Object
277 278 279 280 281 282 283 |
# 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) ⇒ Object
263 264 265 266 267 268 269 |
# 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) ⇒ Object
271 272 273 274 275 |
# File 'lib/bud/labeling/labeling.rb', line 271 def new_class_from_class(cls) Class.new(cls) do include MetaMods end end |
#output_report ⇒ Object
225 226 227 228 229 230 231 232 233 |
# 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 ⇒ Object
235 236 237 238 239 240 241 242 243 244 |
# 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 ⇒ Object
221 222 223 |
# File 'lib/bud/labeling/labeling.rb', line 221 def validate @report = @f.validate if @report.nil? end |
#write_graph(fmt = :pdf) ⇒ Object
285 286 287 |
# File 'lib/bud/labeling/labeling.rb', line 285 def write_graph(fmt=:pdf) f.finish(internal_tabs, "#{@mod.to_s}.#{fmt}", fmt) end |