Module: PrimitiveWrapper
- Defined in:
- lib/primitive_wrapper/version.rb,
lib/primitive_wrapper.rb
Overview
adding rational to fraction
Constant Summary collapse
- VERSION =
"2.1.0"
Class Method Summary collapse
Class Method Details
.copy(dest, source, indexes) ⇒ Object
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 |
# File 'lib/primitive_wrapper.rb', line 1103 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
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
# File 'lib/primitive_wrapper.rb', line 1075 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 |