Class: Processor
- Includes:
- Livetext::Standard
- Defined in:
- lib/livetext/processor.rb
Overview
Class Processor does the actual work of processing input.
Constant Summary collapse
- Disallowed =
i[ __binding__ __id__ __send__ class clone display dup enum_for eql? equal? extend freeze frozen? hash inspect instance_eval instance_exec instance_of? is_a? kind_of? method methods nil? object_id pretty_inspect private_methods protected_methods public_method public_methods public_send respond_to? send singleton_class singleton_method singleton_methods taint tainted? tap to_enum to_s trust untaint untrust untrusted? define_singleton_method instance_variable_defined? instance_variable_get instance_variable_set remove_instance_variable instance_variables ]
Constants included from Livetext::Standard
Livetext::Standard::SimpleFormats, Livetext::Standard::TTY
Constants included from Livetext::Helpers
Livetext::Helpers::Comment, Livetext::Helpers::DollarDot, Livetext::Helpers::DotCmd, Livetext::Helpers::ESCAPING, Livetext::Helpers::Sigil, Livetext::Helpers::Space, Livetext::Helpers::TTY
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Attributes included from Livetext::Standard
Instance Method Summary collapse
- #api ⇒ Object
- #disallowed?(name) ⇒ Boolean
- #error(*args) ⇒ Object
- #html ⇒ Object
-
#initialize(parent, output = nil) ⇒ Processor
constructor
Processor.
- #nextline ⇒ Object
- #output=(io) ⇒ Object
- #peek_nextline ⇒ Object
- #source(enum, file, line) ⇒ Object
Methods included from Livetext::Standard
#backtrace, #banner, #bits, #br, #cinclude, #cleanup, #comment, #copy, #debug, #dlist, #dot_def, #dot_include, #errout, #func, #h1, #h2, #h3, #h4, #h5, #h6, #heading, #heredoc, #heredoc!, #image, #import, #inherit, #link, #list, #list!, #mixin, #mono, #newpage, #nopara, #nopass, #para, #passthru, #quit, #r, #raw, #reflection, #say, #seek, #set, #shell, #shell!, #table, #ttyout, #variables, #variables!, #xtable
Methods included from Livetext::Helpers
#check_disallowed, #check_file_exists, #debug, #escape_html, #find_file, #friendly_error, #get_name_data, #grab_file, #graceful_error, #handle_dollar_dot, #handle_dotcmd, #handle_scomment, #include_file, #invoke_dotcmd, #onoff, #process_file, #process_line, #read_variables, rx, #search_upward, #set_variables, #setfile, #setfile!, #setvar, #showme
Constructor Details
#initialize(parent, output = nil) ⇒ Processor
Processor
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/livetext/processor.rb', line 26 def initialize(parent, output = nil) # Processor @parent = parent || self # STDERR.puts "PARENT.api = #{parent.api.inspect}" @parent.api ||= Livetext::UserAPI.new(@parent) @nopass = false @nopara = false # Meh? @output = ::Livetext.output = (output || File.open("/dev/null", "w")) @sources = [] @indentation = @parent.indentation @_mixins = [] @_imports = [] @html = HTML.new(@parent.api) end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
24 25 26 |
# File 'lib/livetext/processor.rb', line 24 def parent @parent end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
24 25 26 |
# File 'lib/livetext/processor.rb', line 24 def sources @sources end |
Instance Method Details
#api ⇒ Object
41 42 43 |
# File 'lib/livetext/processor.rb', line 41 def api @parent.api # FIXME Is this weird?? end |
#disallowed?(name) ⇒ Boolean
57 58 59 60 |
# File 'lib/livetext/processor.rb', line 57 def disallowed?(name) flag = Disallowed.include?(name.to_sym) flag end |
#error(*args) ⇒ Object
53 54 55 |
# File 'lib/livetext/processor.rb', line 53 def error(*args) ::STDERR.puts *args end |
#html ⇒ Object
45 46 47 |
# File 'lib/livetext/processor.rb', line 45 def html @html end |
#nextline ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/livetext/processor.rb', line 79 def nextline return nil if @sources.empty? line = @sources.last[0].next @sources.last[2] += 1 line rescue StopIteration @sources.pop nil end |
#output=(io) ⇒ Object
49 50 51 |
# File 'lib/livetext/processor.rb', line 49 def output=(io) @output = io end |
#peek_nextline ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/livetext/processor.rb', line 66 def peek_nextline return nil if @sources.empty? source = @sources.last line = source[0].peek line rescue StopIteration @sources.pop nil rescue => err TTY.puts "#{__method__}: RESCUE err = #{err.inspect}" nil end |
#source(enum, file, line) ⇒ Object
62 63 64 |
# File 'lib/livetext/processor.rb', line 62 def source(enum, file, line) @sources.push([enum, file, line]) end |