Module: Livetext::UserAPI
- Included in:
- Processor
- Defined in:
- lib/userapi.rb
Instance Method Summary collapse
- #_args ⇒ Object
- #_body(raw = false, sigil = ".") ⇒ Object
- #_body_text(raw = false, sigil = ".") ⇒ Object
- #_check_existence(file, msg) ⇒ Object
- #_comment?(str, sigil = ".") ⇒ Boolean
- #_debug(*args) ⇒ Object
- #_debug=(val) ⇒ Object
- #_end?(str, sigil = ".") ⇒ Boolean
- #_formatting(line, context = nil) ⇒ Object
- #_handle_escapes(str, set) ⇒ Object
- #_optional_blank_line ⇒ Object
- #_out(str) ⇒ Object
- #_passthru(line, context = nil) ⇒ Object
- #_print(*args) ⇒ Object
- #_puts(*args) ⇒ Object
- #_raw_body(tag = "__EOF__", sigil = ".") ⇒ Object
- #_raw_body!(sigil = ".") ⇒ Object
- #_source ⇒ Object
- #_trailing?(char) ⇒ Boolean
Instance Method Details
#_args ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/userapi.rb', line 15 def _args if block_given? @_args.each {|arg| yield arg } else @_args end end |
#_body(raw = false, sigil = ".") ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/userapi.rb', line 62 def _body(raw=false, sigil=".") lines = [] @save_location = @sources.last loop do @line = nextline raise if @line.nil? break if _end?(@line, sigil) next if _comment?(@line, sigil) # FIXME? @line = _formatting(@line) unless raw lines << @line end _optional_blank_line if block_given? lines.each {|line| yield line } else lines end rescue => err # FIXME _error!("Expecting .end, found end of file") end |
#_body_text(raw = false, sigil = ".") ⇒ Object
84 85 86 |
# File 'lib/userapi.rb', line 84 def _body_text(raw=false, sigil=".") _body(sigil).join("") end |
#_check_existence(file, msg) ⇒ Object
7 8 9 |
# File 'lib/userapi.rb', line 7 def _check_existence(file, msg) _error! msg unless File.exist?(file) end |
#_comment?(str, sigil = ".") ⇒ Boolean
27 28 29 30 31 |
# File 'lib/userapi.rb', line 27 def _comment?(str, sigil=".") c1 = sigil + Livetext::Space c2 = sigil + sigil + Livetext::Space str.index(c1) == 0 || str.index(c2) == 0 end |
#_debug(*args) ⇒ Object
136 137 138 |
# File 'lib/userapi.rb', line 136 def _debug(*args) TTY.puts *args if @_debug end |
#_debug=(val) ⇒ Object
132 133 134 |
# File 'lib/userapi.rb', line 132 def _debug=(val) @_debug = val end |
#_end?(str, sigil = ".") ⇒ Boolean
38 39 40 41 42 43 44 |
# File 'lib/userapi.rb', line 38 def _end?(str, sigil=".") return false if str.nil? cmd = sigil + "end" return false if str.index(cmd) != 0 return false unless _trailing?(str[5]) return true end |
#_formatting(line, context = nil) ⇒ Object
100 101 102 103 104 |
# File 'lib/userapi.rb', line 100 def _formatting(line, context = nil) @parser ||= ::FormatLine.new l2 = @parser.parse(line, context) line.replace(l2) end |
#_handle_escapes(str, set) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/userapi.rb', line 92 def _handle_escapes(str, set) str = str.dup set.each_char do |ch| str.gsub!("\\#{ch}", ch) end str end |
#_optional_blank_line ⇒ Object
23 24 25 |
# File 'lib/userapi.rb', line 23 def _optional_blank_line @line = nextline if peek_nextline =~ /^ *$/ end |
#_out(str) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/userapi.rb', line 116 def _out(str) if @no_puts @body << str else _puts str end end |
#_passthru(line, context = nil) ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/userapi.rb', line 106 def _passthru(line, context = nil) $which = 1 return if @_nopass # p [@_nopara, line] _out "<p>" if line == "\n" and ! @_nopara # _out "<p>" if line == "" and ! @_nopara _formatting(line, context) _out line end |
#_print(*args) ⇒ Object
128 129 130 |
# File 'lib/userapi.rb', line 128 def _print(*args) @output.print *args end |
#_puts(*args) ⇒ Object
124 125 126 |
# File 'lib/userapi.rb', line 124 def _puts(*args) @output.puts *args end |
#_raw_body(tag = "__EOF__", sigil = ".") ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/userapi.rb', line 46 def _raw_body(tag = "__EOF__", sigil = ".") lines = [] @save_location = @sources.last loop do @line = nextline break if @line.chomp.strip == tag lines << @line end _optional_blank_line if block_given? lines.each {|line| yield @line } else lines end end |
#_raw_body!(sigil = ".") ⇒ Object
88 89 90 |
# File 'lib/userapi.rb', line 88 def _raw_body!(sigil=".") _raw_body(sigil).join("\n") end |
#_source ⇒ Object
11 12 13 |
# File 'lib/userapi.rb', line 11 def _source @input end |
#_trailing?(char) ⇒ Boolean
33 34 35 36 |
# File 'lib/userapi.rb', line 33 def _trailing?(char) return true if ["\n", " ", nil].include?(char) return false end |