Module: PrimitiveWrapper

Defined in:
lib/primitive_wrapper/version.rb,
lib/primitive_wrapper.rb

Overview

note: be sure to check if reverse handles … and .. note that there is no exclude start, so reversing will require recalculation or simplification

... put this on the back burner for now

Constant Summary collapse

VERSION =
"2.0.0"

Class Method Summary collapse

Class Method Details

.copy(dest, source, indexes) ⇒ Object



942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
# File 'lib/primitive_wrapper.rb', line 942

def self.copy(dest, source, indexes)
  rtn = []
  if indexes == :all
    if source.type_of? Array
      source.count.times do |idx|
        rtn.push(dest[idx]=source[idx])
      end
    else
      dest.count.times do |idx|
        rtn.push(dest[idx]=source)
      end
    end
  else
    if source.type_of? Array
      ii = 0
      indexes.each do |idx|
        rtn.push(dest[idx]=source[ii])
        ii += 1
      end      
    else
      indexes.each do |idx|
        rtn.push(dest[idx]=source)
      end            
    end
  end
  rtn.count <= 1 ? rtn.first : rtn   
end

.get_list(list, ng = nil) ⇒ Object



914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
# File 'lib/primitive_wrapper.rb', line 914

def self.get_list(list, ng=nil)
  rtn = []
  if list.empty?
    return []
  elsif list.count == 1
    item = list.first
    if item.type_of? Range
      rtn.push item.to_wrapper
    else
      rtn.push item
    end
    return rtn
  end
  list.each do |ii|
    if(ii.type_of? Range)
      ii = ii.to_wrapper
      ii.re_range!(ng)
    end
    if ((ii.type_of? Range) || (ii.type_of? Array))
      ii.each do |idx|
        rtn.push idx
      end
    else 
      rtn.push ii
    end
  end
  return rtn
end