Class: IFF::Chunk
Overview
A generic representation for a YAML chunk; its payload is accessible via the ‘content’ accessor.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tag, content = nil) ⇒ Chunk
constructor
A new instance of Chunk.
- #serialize(stream, options) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(tag, content = nil) ⇒ Chunk
Returns a new instance of Chunk.
41 42 43 44 |
# File 'lib/iff.rb', line 41 def initialize( tag, content=nil ) @tag = tag @content = content.to_s end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
32 33 34 |
# File 'lib/iff.rb', line 32 def content @content end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
31 32 33 |
# File 'lib/iff.rb', line 31 def tag @tag end |
Class Method Details
.unserialize(tag, length, stream, options) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/iff.rb', line 34 def self.unserialize( tag, length, stream, ) content = stream.read( length ) raise EOFError, "Body too short" \ if !content || content.length < length self.new( tag, content ) end |
Instance Method Details
#serialize(stream, options) ⇒ Object
46 47 48 |
# File 'lib/iff.rb', line 46 def serialize( stream, ) stream << content end |