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) ⇒ Sheaf

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



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/api/sheaf.rb', line 45

def initialize(sheaf_chain, expression)
  
  @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

#fragmentsObject (readonly)

Returns the value of attribute fragments.



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

def fragments
  @fragments
end

#modeObject (readonly)

Returns the value of attribute mode.



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

def mode
  @mode
end

#ruleObject (readonly)

Returns the value of attribute rule.



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

def rule
  @rule
end

#sheaf_chainObject (readonly)

Returns the value of attribute sheaf_chain.



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

def sheaf_chain
  @sheaf_chain
end

Instance Method Details

#dst?Boolean

Returns:

  • (Boolean)


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

def dst?; @sheaf_chain.dst?; end

#pObject



60
61
62
63
64
65
66
# File 'lib/api/sheaf.rb', line 60

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

#src?Boolean

Returns:

  • (Boolean)


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

def src?; @sheaf_chain.src?; end