Class: Pione::PNML::Perspective
- Inherits:
-
Object
- Object
- Pione::PNML::Perspective
- Defined in:
- lib/pione/pnml/pione-model.rb
Overview
Perspective
is a meta class for PIONE's concepts overlayed in PNML.
Direct Known Subclasses
ConditionalBranch, ConstituentRule, DataCondition, Param, RuleDefinition
Class Method Summary collapse
- .action_rule?(node) ⇒ Boolean
- .compact(name) ⇒ Object
-
.eliminate_comment(str) ⇒ Object
Eliminate comments from the string.
-
.empty?(node) ⇒ Boolean
Return true if the node is empty in PIONE model.
-
.file?(node) ⇒ Boolean
Return true if the node is a file in PIONE model.
-
.flow_rule?(node) ⇒ Boolean
Return ture if the node is a flow rule.
- .modifier(name) ⇒ Object
-
.named?(node) ⇒ Boolean
Return true if the node is named in PIONE model.
-
.net_input?(node) ⇒ Boolean
Return true if the node is a net's input.
-
.net_output?(node) ⇒ Boolean
Return true if the node is a net's output.
- .normalize_data_name(name) ⇒ Object
-
.param?(node) ⇒ Boolean
Return true if the node is a parameter in PIONE model.
- .remove_comment(name) ⇒ Object
-
.rule?(node) ⇒ Boolean
Return true if the node is a rule.
-
.ticket?(node) ⇒ Boolean
Return true if the node is a ticket in PIONE model.
Class Method Details
.action_rule?(node) ⇒ Boolean
111 112 113 |
# File 'lib/pione/pnml/pione-model.rb', line 111 def self.action_rule?(node) rule?(node) and not(flow_rule?(node)) end |
.compact(name) ⇒ Object
127 128 129 |
# File 'lib/pione/pnml/pione-model.rb', line 127 def self.compact(name) remove_comment(name) end |
.eliminate_comment(str) ⇒ Object
Eliminate comments from the string. This implementation is temporary, we should fix this.
7 8 9 10 |
# File 'lib/pione/pnml/pione-model.rb', line 7 def self.eliminate_comment(str) # FIXME str.sub(/#.*$/, "") end |
.empty?(node) ⇒ Boolean
Return true if the node is empty in PIONE model.
16 17 18 19 20 21 22 |
# File 'lib/pione/pnml/pione-model.rb', line 16 def self.empty?(node) # node should be a place or transition return false unless node.is_a?(Place) or node.is_a?(Transition) return true if node.name.nil? return true if /^[<>]?\s*$/.match(eliminate_comment(node.name.strip)) end |
.file?(node) ⇒ Boolean
Return true if the node is a file in PIONE model.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pione/pnml/pione-model.rb', line 36 def self.file?(node) # files should be represented as a place return false unless node.is_a?(Place) return false if node.name.nil? # normalize name = node.name.strip if name.size > 0 and "<>".include?(name[0]) name = name.sub(/[<>]/, "") end # test return (name.size > 0 and name[0] == "'") end |
.flow_rule?(node) ⇒ Boolean
Return ture if the node is a flow rule.
107 108 109 |
# File 'lib/pione/pnml/pione-model.rb', line 107 def self.flow_rule?(node) rule?(node) and node.name.strip.start_with?("&") end |
.modifier(name) ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/pione/pnml/pione-model.rb', line 155 def self.modifier(name) if name.size > 0 and name.strip[0] == "<" return "<" end if name.size > 0 and name.strip[0] == ">" return ">" end return "" end |
.named?(node) ⇒ Boolean
Return true if the node is named in PIONE model.
28 29 30 |
# File 'lib/pione/pnml/pione-model.rb', line 28 def self.named?(node) not(empty?(node)) end |
.net_input?(node) ⇒ Boolean
Return true if the node is a net's input.
141 142 143 |
# File 'lib/pione/pnml/pione-model.rb', line 141 def self.net_input?(node) node.name and compact(node.name)[0] == "<" end |
.net_output?(node) ⇒ Boolean
Return true if the node is a net's output.
151 152 153 |
# File 'lib/pione/pnml/pione-model.rb', line 151 def self.net_output?(node) node.name and compact(node.name)[0] == ">" end |
.normalize_data_name(name) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/pione/pnml/pione-model.rb', line 115 def self.normalize_data_name(name) return nil if name.nil? name = name.strip name = remove_comment(name) if name.size > 0 and name[0] == "<" or name[0] == ">" name[1..-1].strip else name end end |
.param?(node) ⇒ Boolean
Return true if the node is a parameter in PIONE model.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pione/pnml/pione-model.rb', line 73 def self.param?(node) # parameter node should be represented as a place return false unless node.is_a?(Place) # parameter node should be parsed as param sentence begin Lang::DocumentParser.new.param_sentence.parse(name) return true rescue return false end end |
.remove_comment(name) ⇒ Object
131 132 133 |
# File 'lib/pione/pnml/pione-model.rb', line 131 def self.remove_comment(name) name.sub(/#\s*$/, "").strip end |
.rule?(node) ⇒ Boolean
Return true if the node is a rule.
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/pione/pnml/pione-model.rb', line 92 def self.rule?(node) return false unless node.is_a?(Transition) return false unless not(node.name.nil?) name = node.name.strip # keywords if ["if", "else", "then"].include?(name) return false end return name.size > 0 end |
.ticket?(node) ⇒ Boolean
Return true if the node is a ticket in PIONE model.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/pione/pnml/pione-model.rb', line 55 def self.ticket?(node) # tickets should be represented as a place return false unless node.is_a?(Place) # try parsing as a ticket expression Lang::Parser.ticket_expr.parse(node.name) # the node is a ticket return true rescue Parslet::ParseFailed => e # the node is not a ticket return false end |