Module: PrimitiveWrapper
- Defined in:
- lib/primitive_wrapper/version.rb,
lib/primitive_wrapper.rb
Overview
adding rational to fraction
Constant Summary collapse
- VERSION =
"2.3.0"
Class Method Summary collapse
Class Method Details
.copy(dest, source, indexes) ⇒ Object
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 |
# File 'lib/primitive_wrapper.rb', line 1115 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
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 |
# File 'lib/primitive_wrapper.rb', line 1087 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 |