class Glaemscribe::API::SheafChain
Constants
- SHEAF_REGEXP_IN
- SHEAF_REGEXP_OUT
Attributes
expression[R]
is_src[R]
mode[R]
rule[R]
sheaves[R]
Public Class Methods
new(rule, expression, is_src)
click to toggle source
Pass in the whole member of a rule src => dst (src or dst)
# File lib/api/sheaf_chain.rb, line 58 def initialize(rule, expression, is_src) @rule = rule @mode = rule.mode @is_src = is_src @expression = expression # Split expression with '[...]' patterns. e.g. 'b[a*c*d]e' => [b, a*c*d, e] sheaf_exps = expression.split(SHEAF_REGEXP_OUT).map{ |elt| elt.strip }.reject{ |elt| elt.empty? } sheaf_exps = sheaf_exps.map { |sheaf_exp| sheaf_exp =~ SHEAF_REGEXP_IN linkable = false if $1 # Take the interior of the brackets it was a [...] expression sheaf_exp = $1 linkable = true end { exp: sheaf_exp.strip, linkable: linkable } } @sheaves = sheaf_exps.map{ |sd| Sheaf.new(self, sd[:exp], sd[:linkable]) } @sheaves = [Sheaf.new(self,"",false)] if @sheaves.empty? end
Public Instance Methods
dst?()
click to toggle source
# File lib/api/sheaf_chain.rb, line 55 def dst? ; !is_src ; end
p()
click to toggle source
# File lib/api/sheaf_chain.rb, line 80 def p ret = ("*" * 30) ret += "\n" ret += @expression + "\n" @sheaves.each{ |s| ret += s.p } ret end
src?()
click to toggle source
# File lib/api/sheaf_chain.rb, line 54 def src? ; is_src ; end