File: string_buffer.rb

package info (click to toggle)
ruby-temple 0.10.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 476 kB
  • sloc: ruby: 3,347; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 452 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true
module Temple
  module Generators
    # Implements a string buffer.
    #
    #   _buf = ''
    #   _buf << "static"
    #   _buf << dynamic.to_s
    #   _buf
    #
    # @api public
    class StringBuffer < ArrayBuffer
      def create_buffer
        "#{buffer} = ''.dup"
      end

      def return_buffer
        buffer
      end

      def on_dynamic(code)
        concat("(#{code}).to_s")
      end
    end
  end
end