Class: ComponentEmbeddedRuby::Lexer::StringReader
- Inherits:
-
Object
- Object
- ComponentEmbeddedRuby::Lexer::StringReader
- Defined in:
- lib/component_embedded_ruby/lexer/string_reader.rb
Instance Method Summary collapse
-
#initialize(input_reader, quote_type:, can_interpolate:) ⇒ StringReader
constructor
A new instance of StringReader.
- #read_until_closing_quote ⇒ Object
Constructor Details
#initialize(input_reader, quote_type:, can_interpolate:) ⇒ StringReader
Returns a new instance of StringReader.
6 7 8 9 10 |
# File 'lib/component_embedded_ruby/lexer/string_reader.rb', line 6 def initialize(input_reader, quote_type:, can_interpolate:) @input_reader = input_reader @quote_type = quote_type @can_interpolate = can_interpolate end |
Instance Method Details
#read_until_closing_quote ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/component_embedded_ruby/lexer/string_reader.rb', line 12 def read_until_closing_quote string = "" previous_char = nil current_char = input_reader.current_char loop do input_reader.next previous_char = current_char current_char = input_reader.current_char string += current_char break if current_char == quote_type && string[-1] != "\\" if can_interpolate && string[-2..-1] == '#{' && string[-3] != "\\" string += RubyCodeReader.new(input_reader).read_until_closing_tag string += "}" end end string end |