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.
559 560 561 562 563 |
# File 'lib/fugit/nat.rb', line 559 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.
558 559 560 |
# File 'lib/fugit/nat.rb', line 558 def _data0 @_data0 end |
#_data1 ⇒ Object
Returns the value of attribute _data1.
558 559 560 |
# File 'lib/fugit/nat.rb', line 558 def _data1 @_data1 end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
557 558 559 |
# File 'lib/fugit/nat.rb', line 557 def key @key end |
Instance Method Details
#a ⇒ Object
580 |
# File 'lib/fugit/nat.rb', line 580 def a; [ data0, data1 ]; end |
#append(slot) ⇒ Object
569 570 571 572 573 |
# File 'lib/fugit/nat.rb', line 569 def append(slot) @_data0, @_data1 = conflate(0, slot), conflate(1, slot) @opts.clear self end |
#data0 ⇒ Object
564 |
# File 'lib/fugit/nat.rb', line 564 def data0; @data0 ||= Array(@_data0); end |
#data1 ⇒ Object
565 |
# File 'lib/fugit/nat.rb', line 565 def data1; @data1 ||= Array(@_data1); end |
#graded? ⇒ Boolean
568 |
# File 'lib/fugit/nat.rb', line 568 def graded?; weak || strong; end |
#inspect ⇒ Object
574 575 576 577 578 579 |
# File 'lib/fugit/nat.rb', line 574 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
567 |
# File 'lib/fugit/nat.rb', line 567 def strong; @opts[:strong]; end |
#weak ⇒ Object
566 |
# File 'lib/fugit/nat.rb', line 566 def weak; @opts[:weak]; end |