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
-
#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”
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
#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
42 |
# File 'lib/api/sheaf.rb', line 42 def dst?; @sheaf_chain.dst?; end |
#p ⇒ Object
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
41 |
# File 'lib/api/sheaf.rb', line 41 def src?; @sheaf_chain.src?; end |