Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/m500.rb
Instance Method Summary collapse
- #append_K(a) ⇒ Object
- #is_Dec? ⇒ Boolean
- #is_f? ⇒ Boolean
- #is_Frac? ⇒ Boolean
- #is_K? ⇒ Boolean
- #is_K_Leicht? ⇒ Boolean
- #is_Q? ⇒ Boolean
- #is_R? ⇒ Boolean
- #is_Sig? ⇒ Boolean
- #to_Dec ⇒ Object
- #to_Frac ⇒ Object
- #to_K ⇒ Object
- #to_N ⇒ Object
- #to_N0 ⇒ Object
- #to_Q ⇒ Object
- #to_R ⇒ Object
- #to_Sig ⇒ Object
- #to_ST ⇒ Object
- #to_Z ⇒ Object
Instance Method Details
#append_K(a) ⇒ Object
193 194 195 196 197 |
# File 'lib/m500.rb', line 193 def append_K(a) a = a.to_Frac # "Fraction(Zahlen(#{a.integer.to_s}),Quotient(Zahlen(#{a.properfraction.numerator.to_s}),Zahlen(#{a.properfraction.denominator.to_s})))" self.gsub!("&&&&","Fraction(Zahlen(#{a.integer.to_s}),Quotient(Zahlen(#{a.properfraction.numerator.to_s}),Zahlen(#{a.properfraction.denominator.to_s})))") end |
#is_Dec? ⇒ Boolean
60 61 62 63 64 65 66 |
# File 'lib/m500.rb', line 60 def is_Dec? t = true re = /(\d+)#{Decimal::decimalSeparator}(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? t end |
#is_f? ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/m500.rb', line 39 def is_f? t = true re = /(\-*\d+).(\d+)e([-|+])(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? && md[3].nil? && md[4].nil? t end |
#is_Frac? ⇒ Boolean
46 47 48 49 50 51 52 |
# File 'lib/m500.rb', line 46 def is_Frac? t = true re = /(\d+) (\d+)\/(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? && md[3].nil? && md[4].nil? t end |
#is_K? ⇒ Boolean
179 180 181 182 183 184 185 |
# File 'lib/m500.rb', line 179 def is_K? t = true re = /(\d+)#{Kettenbruch::Separator}(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? t end |
#is_K_Leicht? ⇒ Boolean
186 187 188 189 190 191 192 |
# File 'lib/m500.rb', line 186 def is_K_Leicht? t = true re = /(\d+)#{Kettenbruch::Separator}(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? t end |
#is_Q? ⇒ Boolean
53 54 55 56 57 58 59 |
# File 'lib/m500.rb', line 53 def is_Q? t = true re = /(\d+)\/(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? && md[3].nil? && md[4].nil? t end |
#is_R? ⇒ Boolean
69 70 71 |
# File 'lib/m500.rb', line 69 def is_R? false end |
#is_Sig? ⇒ Boolean
67 68 |
# File 'lib/m500.rb', line 67 def is_Sig? end |
#to_Dec ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/m500.rb', line 134 def to_Dec re = /^-/ md = re.match(self.to_s) e = -1 e = 1 if md.to_a.empty? md = nil t0 = 0 t1 = '0' t2 = nil t3 = nil re = /(\d+)\.(\d+)\[(\d+)\]/ md = re.match(self.to_s) if md.to_a.empty? then re = /(\d+)\.(\d+)/ md = re.match(self.to_s) if md.to_a.empty? then re = /(\d+)\.\[(\d+)\]/ md = re.match(self.to_s) if md.to_a.empty? then re = /(\d+)/ md = re.match(self.to_s) t0 = 0 t1 = '0' t2 = nil t3 = md[1].to_i else t0 = 0 t1 = md[2] #.to_i t2 = nil t3 = md[1].to_i end else t0 = md[2].scan(/^0+/)[0].length unless md[2].scan(/^0+/).empty? t1 = md[3] unless md[3].nil? t2 = md[2].to_i t3 = md[1].to_i end else t0 = md[2].scan(/^0+/)[0].length unless md[2].scan(/^0+/).empty? t1 = md[3] unless md[3].nil? t2 = md[2].to_i t3 = md[1].to_i end Decimal(t3,t2,t1,t0,e) end |
#to_Frac ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/m500.rb', line 97 def to_Frac re = /(^\d+) (\d+)\/(\d+)/ md = re.match(self.to_s) t = nil if not md.nil? then t = Fraction(Zahlen(md[1].to_i),Quotient(md[2].to_i, md[3].to_i)) else re = /^-1\((\d+) (\d+)\/(\d+)\)/ md = re.match(self.to_s) if not md.nil? then t = Fraction(Zahlen(md[1].to_i),Quotient(md[2].to_i, md[3].to_i),-1) unless md.nil? else re = /(\-*\d+)\/(\d+)/ md = re.match(self.to_s) if not md.nil? then t = Fraction(Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i))) else t=Fraction(Quotient(self.to_i,1)) end end end end |
#to_K ⇒ Object
198 199 200 201 202 203 204 205 |
# File 'lib/m500.rb', line 198 def to_K a = self.split(";") int = a.at(0).to_i re = /'...'/ md = re.match(a.at(1)) frK = eval("[" + a.at(1).gsub("...","") + "]" ) ([int] + frK).to_K end |
#to_N ⇒ Object
72 73 74 75 76 77 |
# File 'lib/m500.rb', line 72 def to_N re = /(^\d+)/ md = re.match(self.to_s) t = emptySet t = md[1].to_i.to_N unless md.nil? end |
#to_N0 ⇒ Object
91 92 93 94 95 96 |
# File 'lib/m500.rb', line 91 def to_N0 re = /(\d+)/ md = re.match(self.to_s) t = emptySet t = Counting(md[1].to_i) unless md.nil? end |
#to_Q ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/m500.rb', line 119 def to_Q re = /(\-*\d+)\/(\d+)/ md = re.match(self.to_s) ret = naught if md then t = 1 Natural(md[2].to_i).kind_of?(EmptySetClass) ? ret = infinity : ret = Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i)) else Natural(md[2].to_i).kind_of?(EmptySetClass) ? ret = infinity : ret = Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i)) end ret end |
#to_R ⇒ Object
208 209 210 |
# File 'lib/m500.rb', line 208 def to_R self.to_i end |
#to_Sig ⇒ Object
206 207 |
# File 'lib/m500.rb', line 206 def to_Sig end |