Class: ComponentEmbeddedRuby::Lexer::RubyCodeReader
- Inherits:
-
Object
- Object
- ComponentEmbeddedRuby::Lexer::RubyCodeReader
- Defined in:
- lib/component_embedded_ruby/lexer/ruby_code_reader.rb
Instance Method Summary collapse
-
#initialize(input_reader) ⇒ RubyCodeReader
constructor
A new instance of RubyCodeReader.
- #read_until_closing_tag ⇒ Object
Constructor Details
#initialize(input_reader) ⇒ RubyCodeReader
Returns a new instance of RubyCodeReader.
6 7 8 |
# File 'lib/component_embedded_ruby/lexer/ruby_code_reader.rb', line 6 def initialize(input_reader) @input_reader = input_reader end |
Instance Method Details
#read_until_closing_tag ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/component_embedded_ruby/lexer/ruby_code_reader.rb', line 10 def read_until_closing_tag string = "" loop do input_reader.next current_char = input_reader.current_char break if current_char == "}" string += current_char if current_char == "{" string += RubyCodeReader.new(input_reader).read_until_closing_tag # RubyCodeReader reads until "}", so we have to re-add that # character when reading nested code string += "}" elsif current_char == "'" || current_char == '"' # TODO: this *may* need to handle % syntax strings too string += StringReader.new( input_reader, quote_type: current_char, can_interpolate: current_char == '"' ).read_until_closing_quote end end string end |