Class: Rational
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.yaml_new(klass, tag, val) ⇒ Object
388 389 390 391 392 393 394 |
# File 'lib/syck/rubytypes.rb', line 388 def Rational.yaml_new( klass, tag, val ) if val.is_a? String Rational( val ) else Rational( val['numerator'], val['denominator'] ) end end |
Instance Method Details
#to_yaml(opts = {}) ⇒ Object
395 396 397 398 399 400 401 402 |
# File 'lib/syck/rubytypes.rb', line 395 def to_yaml( opts = {} ) Syck::quick_emit( self, opts ) do |out| out.map( taguri, nil ) do |map| map.add( 'denominator', denominator ) map.add( 'numerator', numerator ) end end end |