Class: Prune::PObjects::PStream

Inherits:
Base
  • Object
show all
Defined in:
lib/prune/p_objects/p_stream.rb

Instance Method Summary collapse

Methods inherited from Base

#indent!, #outdent!, #space, #value_to_s

Constructor Details

#initializePStream

Initialize.



7
8
9
# File 'lib/prune/p_objects/p_stream.rb', line 7

def initialize
  @stream = []
end

Instance Method Details

#<<(text) ⇒ Object

Add content.

Raises:



12
13
14
15
# File 'lib/prune/p_objects/p_stream.rb', line 12

def <<(text)
  raise PStreamTypeError unless text.instance_of?(String)
  @stream << text
end

#lengthObject

Length of the content.



18
19
20
# File 'lib/prune/p_objects/p_stream.rb', line 18

def length
  self.to_s.size
end

#to_sObject

Convert content to string.



23
24
25
# File 'lib/prune/p_objects/p_stream.rb', line 23

def to_s
  ["stream", @stream, "endstream"].flatten.join(LF)
end