Class: Rational
- Inherits:
-
Object
- Object
- Rational
- Defined in:
- lib/json/add/rational.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.json_create(object) ⇒ Object
7 8 9 |
# File 'lib/json/add/rational.rb', line 7 def self.json_create(object) Rational(object['n'], object['d']) end |
Instance Method Details
#as_json ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/json/add/rational.rb', line 11 def as_json(*) { JSON.create_id => self.class.name, 'n' => numerator, 'd' => denominator, } end |
#to_json ⇒ Object
19 20 21 |
# File 'lib/json/add/rational.rb', line 19 def to_json(*) as_json.to_json end |