Project

General

Profile

Bug #7305 ยป ruby_bigdecimal_docs.patch

vbatts (Vincent Batts), 11/08/2012 01:53 AM

View differences:

ext/bigdecimal/bigdecimal.c
335 335
    return INT2FIX(hash);
336 336
}
337 337

  
338
/*
339
 * call-seq: _dump
340
 *
341
 * Method used to provide marshalling support. See the Marshal module.
342
 * 
343
 *      inf = BigDecimal.new('Infinity')
344
 *      => #<BigDecimal:1e16fa8,'Infinity',9(9)>
345
 *      BigDecimal._load(inf._dump)
346
 *      => #<BigDecimal:1df8dc8,'Infinity',9(9)>
347
 *
348
 */
338 349
static VALUE
339 350
BigDecimal_dump(int argc, VALUE *argv, VALUE self)
340 351
{
......
804 815
    return self;
805 816
}
806 817

  
807
 /* call-seq:
818
 /*
819
  * Document-method: BigDecimal#add
820
  * Document-method: BigDecimal#+
821
  *
822
  * call-seq:
808 823
  * add(value, digits)
809 824
  *
810 825
  * Add the specified value.
......
1099 1114
    return ToValue(c);
1100 1115
}
1101 1116

  
1102
 /* call-seq:
1103
  * mult(value, digits)
1117
 /*
1118
  * Document-method: BigDecimal#mult
1119
  *
1120
  * call-seq: mult(value, digits)
1104 1121
  *
1105 1122
  * Multiply by the specified value.
1106 1123
  *
......
2311 2328
    return self;
2312 2329
}
2313 2330

  
2331
/* :nodoc:
2332
 * 
2333
 * private method to clone to clone the provided BigDecimal +other+
2334
 */
2314 2335
static VALUE
2315 2336
BigDecimal_initialize_copy(VALUE self, VALUE other)
2316 2337
{
......
2433 2454
    return INT2FIX(s);
2434 2455
}
2435 2456

  
2436
/* call-seq:
2437
 * BigDecimal.save_exception_mode { ... }
2457
/*
2458
 * call-seq: BigDecimal.save_exception_mode { ... }
2459
 *
2460
 * Excecute the provided block, but preserve the exception mode
2461
 * 
2462
 *     BigDecimal.save_exception_mode do
2463
 *       BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
2464
 *       BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
2465
 *       
2466
 *       BigDecimal.new(BigDecimal('Infinity'))
2467
 *       BigDecimal.new(BigDecimal('-Infinity'))
2468
 *       BigDecimal(BigDecimal.new('NaN'))
2469
 *     end
2470
 *
2471
 * For use with the BigDecimal::EXCEPTION_*
2472
 * See BigDecimal.mode
2438 2473
 */
2439 2474
static VALUE
2440 2475
BigDecimal_save_exception_mode(VALUE self)
......
2447 2482
    return ret;
2448 2483
}
2449 2484

  
2450
/* call-seq:
2451
 * BigDecimal.save_rounding_mode { ... }
2485
/*
2486
 * call-seq: BigDecimal.save_rounding_mode { ... }
2487
 * 
2488
 * Excecute the provided block, but preserve the rounding mode
2489
 *
2490
 *     BigDecimal.save_exception_mode do
2491
 *       BigDecimal.mode(BigDecimal::ROUND_MODE, :up)
2492
 *       puts BigDecimal.mode(BigDecimal::ROUND_MODE)
2493
 *     end
2494
 *
2495
 * For use with the BigDecimal::ROUND_*
2496
 * See BigDecimal.mode
2452 2497
 */
2453 2498
static VALUE
2454 2499
BigDecimal_save_rounding_mode(VALUE self)
......
2461 2506
    return ret;
2462 2507
}
2463 2508

  
2464
/* call-seq:
2465
 * BigDecimal.save_limit { ... }
2509
/*
2510
 * call-seq: BigDecimal.save_limit { ... }
2511
 *
2512
 * Excecute the provided block, but preserve the precision limit
2513
 * 
2514
 *      BigDecimal.limit(100)
2515
 *      puts BigDecimal.limit
2516
 *      BigDecimal.save_limit do
2517
 *          BigDecimal.limit(200)
2518
 *          puts BigDecimal.limit
2519
 *      end
2520
 *      puts BigDecimal.limit
2521
 *
2466 2522
 */
2467 2523
static VALUE
2468 2524
BigDecimal_save_limit(VALUE self)
ext/json/lib/json/add/bigdecimal.rb
4 4
defined?(::BigDecimal) or require 'bigdecimal'
5 5

  
6 6
class BigDecimal
7
  # Import a JSON Marshalled object.
8
  #
9
  # method used for JSON marshalling support.
7 10
  def self.json_create(object)
8 11
    BigDecimal._load object['b']
9 12
  end
10 13

  
14
  # Marshal the object to JSON.
15
  #
16
  # method used for JSON marshalling support.
11 17
  def as_json(*)
12 18
    {
13 19
      JSON.create_id => self.class.name,
......
15 21
    }
16 22
  end
17 23

  
24
  # return the JSON value 
18 25
  def to_json(*)
19 26
    as_json.to_json
20 27
  end