class Pione::PNML::AnnotationExtractor

Public Class Methods

new(net, option) click to toggle source
# File lib/pione/pnml/annotation-extractor.rb, line 4
def initialize(net, option)
  @net = net
  @flow_name = option[:flow_name] || "Main"
  @package_name = option[:package_name]
  @editor = option[:editor]
  @tag = option[:tag]
end

Public Instance Methods

extract() click to toggle source

Extract annotations from transitions.

# File lib/pione/pnml/annotation-extractor.rb, line 17
def extract
  package_annotations = []

  @net.transitions.each do |transition|
    if line = extract_annotation(transition)
      package_annotations << line
    end
  end

  package_annotations << ".@ PackageName :: \"%s\"" % @package_name if @package_name
  package_annotations << ".@ Editor :: \"%s\"" % @editor if @editor
  package_annotations << ".@ Tag :: \"%s\"" % @tag if @tag

  return package_annotations
end

Private Instance Methods

extract_annotation(transition) click to toggle source

Extract an annotation from the transition. If the transition has the name that we can parse as an annotation declarartion sentence, return the name as is. Otherwise, return nil.

# File lib/pione/pnml/annotation-extractor.rb, line 38
def extract_annotation(transition)
  name = transition.name
  Lang::DocumentParser.new.annotation_sentence.parse(name)
  return name
rescue Parslet::ParseFailed => e
  return nil
end