Class: BBCoder::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/bbcoder/buffer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuffer

Returns a new instance of Buffer.



5
6
7
8
# File 'lib/bbcoder/buffer.rb', line 5

def initialize
  @_internal = {}
  @tags = BBCoder::BufferTags.new(self)
end

Instance Attribute Details

#_internalObject

Returns the value of attribute _internal.



3
4
5
# File 'lib/bbcoder/buffer.rb', line 3

def _internal
  @_internal
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/bbcoder/buffer.rb', line 3

def tags
  @tags
end

Instance Method Details

#depthObject

delegates to tags



25
26
27
# File 'lib/bbcoder/buffer.rb', line 25

def depth
  tags.size
end

#joinObject

end of processing, insert any orphaned tags without conversion



20
21
22
# File 'lib/bbcoder/buffer.rb', line 20

def join
  push(tags.join)
end

#pop(depth_modifier = 0) ⇒ Object



15
16
17
# File 'lib/bbcoder/buffer.rb', line 15

def pop(depth_modifier = 0)
  _internal.delete(depth + depth_modifier)
end

#push(content) ⇒ Object



10
11
12
13
# File 'lib/bbcoder/buffer.rb', line 10

def push(content)
  _internal[depth] ||= ""
  _internal[depth] += content
end