public static MutableString/*!*/ Format(RubyContext/*!*/ context, MutableString/*!*/ self, object arg) {
     IList args = arg as IList;
     if (args == null) {
         args = new object[] { arg };
     }
     StringFormatter formatter = new StringFormatter(context, self.ConvertToString(), args);
     return formatter.Format().TaintBy(self);
 }
Beispiel #2
0
 public static string/*!*/ Format(StringFormatterSiteStorage/*!*/ storage, string/*!*/ self, [NotNull]IList/*!*/ args) {
     StringFormatter formatter = new StringFormatter(storage, self, RubyEncoding.UTF8, args);
     return formatter.Format().ToString();
 }
Beispiel #3
0
 private void WriteFloat(double value) {
     // TODO: Ruby appears to have an optimization that saves the (binary) mantissa at the end of the string
     _writer.Write((byte)'f');
     if (Double.IsInfinity(value)) {
         if (Double.IsPositiveInfinity(value)) {
             WriteStringValue(_positiveInfinityString);
         } else {
             WriteStringValue(_negativeInfinityString);
         }
     } else if (Double.IsNaN(value)) {
         WriteStringValue(_nanString);
     } else {
         StringFormatter sf = new StringFormatter(_context, "%.15g", RubyEncoding.Binary, new object[] { value });
         sf.TrailingZeroAfterWholeFloat = false;
         WriteStringValue(sf.Format());
     }
 }
Beispiel #4
0
 public static MutableString/*!*/ Format(StringFormatterSiteStorage/*!*/ storage, MutableString/*!*/ self, object arg) {
     IList args = arg as IList ?? new object[] { arg };
     StringFormatter formatter = new StringFormatter(storage, self.ConvertToString(), self.Encoding, args);
     return formatter.Format().TaintBy(self);
 }
Beispiel #5
0
 public static MutableString ToS(RubyContext/*!*/ context, double self) {
     StringFormatter sf = new StringFormatter(context, "%.15g", new object[] { self });
     sf.TrailingZeroAfterWholeFloat = true;
     return sf.Format();
 }
Beispiel #6
0
        public static MutableString/*!*/ Format(
            ConversionStorage<IntegerValue>/*!*/ integerCast,
            ConversionStorage<int>/*!*/ fixnumCast,
            ConversionStorage<double>/*!*/ tofConversion, 
            ConversionStorage<MutableString>/*!*/ tosConversion,
            UnaryOpStorage/*!*/ inspectStorage,
            RubyContext/*!*/ context, MutableString/*!*/ self, object arg) {

            IList args = arg as IList ?? new object[] { arg };

            StringFormatter formatter = new StringFormatter(integerCast, fixnumCast, tofConversion, tosConversion, inspectStorage, context, 
                self.ConvertToString(), args
            );

            return formatter.Format().TaintBy(self);
        }
Beispiel #7
0
 public static MutableString/*!*/ Format(StringFormatterSiteStorage/*!*/ storage, MutableString/*!*/ self, [NotNull]IList/*!*/ args) {
     StringFormatter formatter = new StringFormatter(storage, self.ConvertToString(), self.Encoding, args);
     return formatter.Format().TaintBy(self);
 }
Beispiel #8
0
 public static string/*!*/ Format(StringFormatterSiteStorage/*!*/ storage, string/*!*/ self, object arg) {
     IList args = arg as IList ?? new object[] { arg };
     StringFormatter formatter = new StringFormatter(storage, self, args);
     return formatter.Format().ToString();
 }
Beispiel #9
0
        public static string /*!*/ Format(StringFormatterSiteStorage /*!*/ storage, string /*!*/ self, [NotNull] IList /*!*/ args)
        {
            StringFormatter formatter = new StringFormatter(storage, self, RubyEncoding.UTF8, args);

            return(formatter.Format().ToString());
        }