Class: Keisan::StringAndGroupParser::StringPortion
- Defined in:
- lib/keisan/string_and_group_parser.rb
Instance Attribute Summary collapse
-
#escaped_string ⇒ Object
readonly
Returns the value of attribute escaped_string.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Attributes inherited from Portion
Instance Method Summary collapse
-
#initialize(expression, start_index) ⇒ StringPortion
constructor
A new instance of StringPortion.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(expression, start_index) ⇒ StringPortion
Returns a new instance of StringPortion.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/keisan/string_and_group_parser.rb', line 14 def initialize(expression, start_index) super(start_index) @string = expression[start_index] @escaped_string = expression[start_index] @end_index = start_index + 1 while @end_index < expression.size if expression[@end_index] == quote_type @string << quote_type @escaped_string << quote_type @end_index += 1 # Successfully parsed the string return end n, c = get_potentially_escaped_next_character(expression, @end_index) @escaped_string << c @end_index += n end raise Keisan::Exceptions::TokenizingError.new("Tokenizing error, no closing quote #{quote_type}") end |
Instance Attribute Details
#escaped_string ⇒ Object (readonly)
Returns the value of attribute escaped_string.
12 13 14 |
# File 'lib/keisan/string_and_group_parser.rb', line 12 def escaped_string @escaped_string end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
12 13 14 |
# File 'lib/keisan/string_and_group_parser.rb', line 12 def string @string end |
Instance Method Details
#size ⇒ Object
38 39 40 |
# File 'lib/keisan/string_and_group_parser.rb', line 38 def size string.size end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/keisan/string_and_group_parser.rb', line 42 def to_s string end |