Class: ErbPP::CountLnString
- Inherits:
-
String
- Object
- String
- ErbPP::CountLnString
- Defined in:
- ext/cumo/narray/gen/erbln.rb
Instance Method Summary collapse
- #concat0(s) ⇒ Object
- #concat1(s) ⇒ Object
- #d(s) ⇒ Object
- #final ⇒ Object
-
#initialize(filename) ⇒ CountLnString
constructor
A new instance of CountLnString.
- #ln(status = nil) ⇒ Object
- #report_line ⇒ Object
Constructor Details
#initialize(filename) ⇒ CountLnString
Returns a new instance of CountLnString.
9 10 11 12 13 14 15 16 17 |
# File 'ext/cumo/narray/gen/erbln.rb', line 9 def initialize(filename) @filename = filename @lnchar = "\n" @buf = +"" @str = +"" @countln = 1 @current = 1 super("\n" + report_line) end |
Instance Method Details
#concat0(s) ⇒ Object
23 24 25 26 27 |
# File 'ext/cumo/narray/gen/erbln.rb', line 23 def concat0(s) ln(caller[0]) @buf.concat(s) @str.concat(s) end |
#concat1(s) ⇒ Object
29 30 31 32 |
# File 'ext/cumo/narray/gen/erbln.rb', line 29 def concat1(s) ln(caller[0]) @buf.concat(s) end |
#d(s) ⇒ Object
90 91 92 93 |
# File 'ext/cumo/narray/gen/erbln.rb', line 90 def d(s) p [s, [x, y], r] r end |
#final ⇒ Object
95 96 97 98 |
# File 'ext/cumo/narray/gen/erbln.rb', line 95 def final ln(caller[0]) concat(@buf) end |
#ln(status = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'ext/cumo/narray/gen/erbln.rb', line 34 def ln(status=nil) case status when /:(\d+):/ n = $1.to_i else n = status.to_i end return if n == @current if @current != @countln || @postpone if /\A\s*\z/ =~ @str || /\A#line / =~ @buf @postpone = true elsif @in_comment @postpone = false else if self[-1] != "\n" concat("\n") end concat(report_line) @postpone = false end end concat(@buf) b = @buf.gsub(/".*?(?<!\\)"/, '""') /^.*(\/\*)(.*?)$/ =~ b x = $2 /^.*(\*\/)(.*?)$/ =~ b y = $2 if x if y if x.size < y.size #:in_comment @in_comment = true else #:out_comment @in_comment = false end else #:in_comment @in_comment = true end else if y #:out_comment @in_comment = false else #:keep end end @countln = @current + @buf.count(@lnchar) @current = n @buf = +"" @str = +"" end |
#report_line ⇒ Object
19 20 21 |
# File 'ext/cumo/narray/gen/erbln.rb', line 19 def report_line "#line #{@current} \"#{@filename}\"\n" end |