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.



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

#_data0Object

Returns the value of attribute _data0.



558
559
560
# File 'lib/fugit/nat.rb', line 558

def _data0
  @_data0
end

#_data1Object

Returns the value of attribute _data1.



558
559
560
# File 'lib/fugit/nat.rb', line 558

def _data1
  @_data1
end

#keyObject (readonly)

Returns the value of attribute key.



557
558
559
# File 'lib/fugit/nat.rb', line 557

def key
  @key
end

Instance Method Details

#aObject



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

#data0Object



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

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

#data1Object



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

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

#graded?Boolean

Returns:

  • (Boolean)


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

def graded?; weak || strong; end

#inspectObject



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

#strongObject



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

def strong; @opts[:strong]; end

#weakObject



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

def weak; @opts[:weak]; end