Class: Mapi::Pst::ID2Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/mapi/pst.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pst, list) ⇒ ID2Mapping

Returns a new instance of ID2Mapping.



828
829
830
831
832
833
834
835
836
837
838
839
840
# File 'lib/mapi/pst.rb', line 828

def initialize pst, list
	@pst = pst
	@list = list
	# create a lookup. 
	@id_from_id2 = {}
	@list.each do |id2|
		# NOTE we take the last value seen value if there are duplicates. this "fixes"
		# test4-o1997.pst for the time being.
		warn "there are duplicate id2 records with id #{id2.id2}" if @id_from_id2[id2.id2]
		next if @id_from_id2[id2.id2]
		@id_from_id2[id2.id2] = id2.id
	end
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



827
828
829
# File 'lib/mapi/pst.rb', line 827

def list
  @list
end

Instance Method Details

#[](id) ⇒ Object

corresponds to:

  • _pst_getID2



849
850
851
852
853
# File 'lib/mapi/pst.rb', line 849

def [] id
	#id2 = @list.find { |x| x.id2 == id }
	id = @id_from_id2[id]
	id and @pst.idx_from_id(id)
end

#warn(s) ⇒ Object

TODO: fix logging



843
844
845
# File 'lib/mapi/pst.rb', line 843

def warn s
	Mapi::Log.warn s
end