# class Range

### Public Class Methods

yaml_new( klass, tag, val ) click to toggle source

    # File lib/syck/rubytypes.rb, line 209
    def Range.yaml_new( klass, tag, val )
        inr = %r'(\w+|[+-]?\d+(?:\.\d+)?(?:e[+-]\d+)?|"(?:[^\\"]|\\.)*")'
        opts = {}
        if String === val and val =~ /^#{inr}(\.{2,3})#{inr}$/o
            r1, rdots, r2 = $1, $2, $3
            opts = {
                'begin' => Syck.load( "--- #{r1}" ),
                'end' => Syck.load( "--- #{r2}" ),
                'excl' => rdots.length == 3
            }
            val = {}
        elsif Hash === val
            opts['begin'] = val.delete('begin')
            opts['end'] = val.delete('end')
            opts['excl'] = val.delete('excl')
        end
        if Hash === opts
            r = Syck::object_maker( klass, {} )
            # Thank you, NaHi
            Range.instance_method(:initialize).
                  bind(r).
                  call( opts['begin'], opts['end'], opts['excl'] )
            val.each { |k,v| r.instance_variable_set( k, v ) }
            r
        else
            raise Syck::TypeError, "Invalid Range: " + val.inspect
        end
    end

### Public Instance Methods

to_yaml( opts = {} ) click to toggle source
Calls superclass method Object#to_yaml

    # File lib/syck/rubytypes.rb, line 237
    def to_yaml( opts = {} )
    return super unless YAML == Syck
            Syck::quick_emit( self, opts ) do |out|
        # if self.begin.is_complex_yaml? or self.begin.respond_to? :to_str or
        #   self.end.is_complex_yaml? or self.end.respond_to? :to_str or
        #   not to_yaml_properties.empty?
            out.map( taguri, to_yaml_style ) do |map|
                map.add( 'begin', self.begin )
                map.add( 'end', self.end )
                map.add( 'excl', self.exclude_end? )
                to_yaml_properties.each do |m|
                    map.add( m, instance_variable_get( m ) )
                end
            end
        # else
        #     out.scalar( taguri ) do |sc|
        #         sc.embed( self.begin )
        #         sc.concat( self.exclude_end? ? "..." : ".." )
        #         sc.embed( self.end )
        #     end
        # end
    end
    end