Class: Hprose::Writer::RealWriterRefer
- Inherits:
-
Object
- Object
- Hprose::Writer::RealWriterRefer
show all
- Includes:
- Tags
- Defined in:
- lib/hprose/io.rb
Constant Summary
Constants included
from Tags
Tags::TagArgument, Tags::TagBytes, Tags::TagCall, Tags::TagClass, Tags::TagClosebrace, Tags::TagDate, Tags::TagDouble, Tags::TagEmpty, Tags::TagEnd, Tags::TagError, Tags::TagFalse, Tags::TagFunctions, Tags::TagGuid, Tags::TagInfinity, Tags::TagInteger, Tags::TagList, Tags::TagLong, Tags::TagMap, Tags::TagNaN, Tags::TagNeg, Tags::TagNine, Tags::TagNull, Tags::TagObject, Tags::TagOpenbrace, Tags::TagPoint, Tags::TagPos, Tags::TagQuote, Tags::TagRef, Tags::TagResult, Tags::TagSemicolon, Tags::TagString, Tags::TagTime, Tags::TagTrue, Tags::TagUTC, Tags::TagUTF8Char, Tags::TagZero
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RealWriterRefer.
647
648
649
650
|
# File 'lib/hprose/io.rb', line 647
def initialize()
@ref = {}
@refcount = 0
end
|
Instance Method Details
#reset ⇒ Object
665
666
667
668
|
# File 'lib/hprose/io.rb', line 665
def reset
@ref.clear
@refcount = 0
end
|
#set(val) ⇒ Object
651
652
653
654
|
# File 'lib/hprose/io.rb', line 651
def set(val)
@ref[val.object_id] = @refcount
@refcount += 1
end
|
#write(stream, val) ⇒ Object
655
656
657
658
659
660
661
662
663
664
|
# File 'lib/hprose/io.rb', line 655
def write(stream, val)
id = val.object_id
if @ref.key?(id) then
stream.putc(TagRef)
stream.write(@ref[id].to_s)
stream.putc(TagSemicolon)
return true
end
return false
end
|