Module: PrimitiveWrapper
- Defined in:
- lib/primitive_wrapper.rb,
lib/primitive_wrapper/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Class Method Summary collapse
Class Method Details
.copy(dest, source, indexes) ⇒ Object
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 |
# File 'lib/primitive_wrapper.rb', line 920 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
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
# File 'lib/primitive_wrapper.rb', line 892 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 |