class Pione::PNML::RuleDefinition
Constants
- ACTION_RULE_TEMPLATE
- FLOW_RULE_TEMPLATE
- LITERATE_ACTION_RULE_TEMPLATE
- WRAPPER_TEMPLATE
Attributes
action_content[RW]
conditions[RW]
constraints[RW]
features[RW]
flow_elements[RW]
inputs[RW]
outputs[RW]
params[RW]
source_tickets[RW]
target_tickets[RW]
type[RW]
variable_bindings[RW]
Public Class Methods
new(name, type, is_external, net_name, index, option={})
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 750 def initialize(name, type, is_external, net_name, index, option={}) @name = name @type = type @is_external = is_external @net_name = net_name @index = index @inputs = option[:inputs] || [] @outputs = option[:outputs] || [] @params = option[:params] || [] @constraints = option[:constraints] || [] @features = option[:features] || [] @source_tickets = option[:source_tickets] || [] @target_tickets = option[:target_tickets] || [] @variable_bindings = option[:variable_bindings] || [] @conditions = option[:conditions] || [] @flow_elements = option[:flow_elements] || [] @action_content = nil end
Public Instance Methods
action?()
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 773 def action? @type == :action end
as_declaration(option={})
click to toggle source
Return the declaration form string.
# File lib/pione/pnml/pione-model.rb, line 786 def as_declaration(option={}) expr_source_tickets = if @source_tickets.size > 0 "(%s) ==> " % @source_tickets.map {|ticket| "%s" % ticket.name}.join(" | ") else "" end expr_target_tickets = if @target_tickets.size > 0 " ==> (%s)" % @target_tickets.map {|ticket| "%s" % ticket.name}.join(" | ") else "" end "rule %s%s%s" % [expr_source_tickets, name, expr_target_tickets] end
external?()
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 777 def external? @is_external end
flow?()
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 769 def flow? @type == :flow end
generate_wrapper_name(name)
click to toggle source
Generate a name for wrapper rule.
# File lib/pione/pnml/pione-model.rb, line 876 def generate_wrapper_name(name) "__%s_%s_%s__" % [@net_name, @name, @index] end
name()
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 781 def name external? ? generate_wrapper_name(@name) : @name end
rule_conditions()
click to toggle source
Make rule conditions.
@return [Array<String>]
rule condition lines
# File lib/pione/pnml/pione-model.rb, line 806 def rule_conditions conditions = [] sort_data_list(@inputs).each do |input| conditions << input.as_declaration end sort_data_list(@outputs).each do |output| conditions << output.as_declaration end @params.each do |param| if param.kind_of?(Param) conditions += param.as_declarations else conditions << param end end @constraints.each do |constraint| if constraint.kind_of?(Constraint) conditions << constraint.as_declaration else conditions << constraint end end @features.each do |feature| if feature.kind_of?(Feature) conditions << feature.as_declaration else conditions << feature end end conditions end
sort_data_list(data_list)
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 838 def sort_data_list(data_list) data_list.sort do |a, b| priority_a = a.priority priority_b = b.priority if a.priority and b.priority a.priority <=> b.priority elsif a.priority 1 elsif b.priority -1 else 0 end end end
template()
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 859 def template if external? return Util::Indentation.cut(WRAPPER_TEMPLATE) end if flow? return Util::Indentation.cut(FLOW_RULE_TEMPLATE) end if @action_content return Util::Indentation.cut(LITERATE_ACTION_RULE_TEMPLATE) else return Util::Indentation.cut(ACTION_RULE_TEMPLATE) end end
textize()
click to toggle source
# File lib/pione/pnml/pione-model.rb, line 855 def textize ERB.new(template, nil, "-").result(binding) end