Class: Rational
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.yaml_new(klass, tag, val) ⇒ Object
400 401 402 403 404 405 406 |
# File 'lib/syck/rubytypes.rb', line 400 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
407 408 409 410 411 412 413 414 415 |
# File 'lib/syck/rubytypes.rb', line 407 def to_yaml( opts = {} ) return super unless YAML == Syck Syck::quick_emit( self, opts ) do |out| out.map( taguri, nil ) do |map| map.add( 'denominator', denominator ) map.add( 'numerator', numerator ) end end end |