Class: Fugit::Nat::Slot

Inherits:
Object
  • Object
show all
Defined in:
lib/fugit/nat.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#_data0Object

Returns the value of attribute _data0.



570
571
572
# File 'lib/fugit/nat.rb', line 570

def _data0
  @_data0
end

#_data1Object

Returns the value of attribute _data1.



570
571
572
# File 'lib/fugit/nat.rb', line 570

def _data1
  @_data1
end

#keyObject (readonly)

Returns the value of attribute key.



569
570
571
# File 'lib/fugit/nat.rb', line 569

def key
  @key
end

Instance Method Details

#aObject



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

#data0Object



576
# File 'lib/fugit/nat.rb', line 576

def data0; @data0 ||= Array(@_data0); end

#data1Object



577
# File 'lib/fugit/nat.rb', line 577

def data1; @data1 ||= Array(@_data1); end

#graded?Boolean

Returns:

  • (Boolean)


580
# File 'lib/fugit/nat.rb', line 580

def graded?; weak || strong; end

#inspectObject



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

#strongObject



579
# File 'lib/fugit/nat.rb', line 579

def strong; @opts[:strong]; end

#weakObject



578
# File 'lib/fugit/nat.rb', line 578

def weak; @opts[:weak]; end