Class: Glaemscribe::API::Sheaf
- Inherits:
-
Object
- Object
- Glaemscribe::API::Sheaf
- Defined in:
- lib/api/sheaf.rb
Constant Summary collapse
- SHEAF_SEPARATOR =
"*"
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#sheaf_chain ⇒ Object
readonly
Returns the value of attribute sheaf_chain.
Instance Method Summary collapse
- #dst? ⇒ Boolean
-
#initialize(sheaf_chain, expression) ⇒ Sheaf
constructor
Should pass a sheaf expression, e.g.
- #p ⇒ Object
- #src? ⇒ Boolean
Constructor Details
#initialize(sheaf_chain, expression) ⇒ Sheaf
Should pass a sheaf expression, e.g. : “h, s, t”
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/api/sheaf.rb', line 47 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
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
39 40 41 |
# File 'lib/api/sheaf.rb', line 39 def expression @expression end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
34 35 36 |
# File 'lib/api/sheaf.rb', line 34 def fragments @fragments end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
36 37 38 |
# File 'lib/api/sheaf.rb', line 36 def mode @mode end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
37 38 39 |
# File 'lib/api/sheaf.rb', line 37 def rule @rule end |
#sheaf_chain ⇒ Object (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
44 |
# File 'lib/api/sheaf.rb', line 44 def dst?; @sheaf_chain.dst?; end |
#p ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/api/sheaf.rb', line 62 def p ret = "-- " + @expression + "\n" @fragments.each{ |l| ret += l.p } ret end |
#src? ⇒ Boolean
43 |
# File 'lib/api/sheaf.rb', line 43 def src?; @sheaf_chain.src?; end |