Class: Glaemscribe::API::Sheaf

Inherits:
Object
  • Object
show all
Defined in:
lib/api/sheaf.rb

Constant Summary collapse

SHEAF_SEPARATOR =
"*"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sheaf_chain, expression, linkable) ⇒ Sheaf

Should pass a sheaf expression, e.g. : “h, s, t”



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/api/sheaf.rb', line 48

def initialize(sheaf_chain, expression, linkable)
  
  @linkable     = linkable
  @sheaf_chain  = sheaf_chain
  @mode         = sheaf_chain.mode
  @rule         = sheaf_chain.rule
  @expression   = expression
  
  # Split members using "*" separator, KEEP NULL MEMBERS (this is legal)
  fragment_exps = expression.split(SHEAF_SEPARATOR,-1).map{|fragment_exp| fragment_exp.strip } 
  fragment_exps = [""] if fragment_exps.empty? # For NULL
           
  # Build the fragments inside
  @fragments = fragment_exps.map{ |fragment_exp|  Fragment.new(self, fragment_exp) }
end

Instance Attribute Details

#expressionObject (readonly)

Returns the value of attribute expression.



40
41
42
# File 'lib/api/sheaf.rb', line 40

def expression
  @expression
end

#fragmentsObject (readonly)

Returns the value of attribute fragments.



35
36
37
# File 'lib/api/sheaf.rb', line 35

def fragments
  @fragments
end

#linkableObject (readonly)

Returns the value of attribute linkable.



34
35
36
# File 'lib/api/sheaf.rb', line 34

def linkable
  @linkable
end

#modeObject (readonly)

Returns the value of attribute mode.



37
38
39
# File 'lib/api/sheaf.rb', line 37

def mode
  @mode
end

#ruleObject (readonly)

Returns the value of attribute rule.



38
39
40
# File 'lib/api/sheaf.rb', line 38

def rule
  @rule
end

#sheaf_chainObject (readonly)

Returns the value of attribute sheaf_chain.



36
37
38
# File 'lib/api/sheaf.rb', line 36

def sheaf_chain
  @sheaf_chain
end

Instance Method Details

#dst?Boolean

Returns:

  • (Boolean)


45
# File 'lib/api/sheaf.rb', line 45

def dst?; @sheaf_chain.dst?; end

#pObject



64
65
66
67
68
69
70
# File 'lib/api/sheaf.rb', line 64

def p
  ret = "-- " + @expression + "\n"
  @fragments.each{ |l|
    ret += l.p
  }
  ret
end

#src?Boolean

Returns:

  • (Boolean)


44
# File 'lib/api/sheaf.rb', line 44

def src?; @sheaf_chain.src?; end