Class: Fugit::Nat::Slot
- Inherits:
-
Object
- Object
- Fugit::Nat::Slot
- Defined in:
- lib/fugit/nat.rb
Instance Attribute Summary collapse
-
#_data0 ⇒ Object
Returns the value of attribute _data0.
-
#_data1 ⇒ Object
Returns the value of attribute _data1.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #a ⇒ Object
- #append(slot) ⇒ Object
- #data0 ⇒ Object
- #data1 ⇒ Object
- #graded? ⇒ Boolean
-
#initialize(key, d0, d1 = nil, opts = nil) ⇒ Slot
constructor
A new instance of Slot.
- #inspect ⇒ Object
- #strong ⇒ Object
- #weak ⇒ Object
Constructor Details
#initialize(key, d0, d1 = nil, opts = nil) ⇒ Slot
Returns a new instance of Slot.
571 572 573 574 575 |
# File 'lib/fugit/nat.rb', line 571 def initialize(key, d0, d1=nil, opts=nil) d1, opts = d1.is_a?(Symbol) ? [ nil, d1 ] : [ d1, opts ] @key, @_data0, @_data1 = key, d0, d1 @opts = (opts.is_a?(Symbol) ? { opts => true } : opts) || {} end |
Instance Attribute Details
#_data0 ⇒ Object
Returns the value of attribute _data0.
570 571 572 |
# File 'lib/fugit/nat.rb', line 570 def _data0 @_data0 end |
#_data1 ⇒ Object
Returns the value of attribute _data1.
570 571 572 |
# File 'lib/fugit/nat.rb', line 570 def _data1 @_data1 end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
569 570 571 |
# File 'lib/fugit/nat.rb', line 569 def key @key end |
Instance Method Details
#a ⇒ Object
592 |
# File 'lib/fugit/nat.rb', line 592 def a; [ data0, data1 ]; end |
#append(slot) ⇒ Object
581 582 583 584 585 |
# File 'lib/fugit/nat.rb', line 581 def append(slot) @_data0, @_data1 = conflate(0, slot), conflate(1, slot) @opts.clear self end |
#data0 ⇒ Object
576 |
# File 'lib/fugit/nat.rb', line 576 def data0; @data0 ||= Array(@_data0); end |
#data1 ⇒ Object
577 |
# File 'lib/fugit/nat.rb', line 577 def data1; @data1 ||= Array(@_data1); end |
#graded? ⇒ Boolean
580 |
# File 'lib/fugit/nat.rb', line 580 def graded?; weak || strong; end |
#inspect ⇒ Object
586 587 588 589 590 591 |
# File 'lib/fugit/nat.rb', line 586 def inspect a = [ @key, @_data0 ] a << @_data1 if @_data1 != nil a << @opts if @opts && @opts.keys.any? "(slot #{a.collect(&:inspect).join(' ')})" end |
#strong ⇒ Object
579 |
# File 'lib/fugit/nat.rb', line 579 def strong; @opts[:strong]; end |
#weak ⇒ Object
578 |
# File 'lib/fugit/nat.rb', line 578 def weak; @opts[:weak]; end |