Class: Keisan::StringAndGroupParser::OtherPortion
- Defined in:
- lib/keisan/string_and_group_parser.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Attributes inherited from Portion
Instance Method Summary collapse
-
#initialize(expression, start_index) ⇒ OtherPortion
constructor
A new instance of OtherPortion.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(expression, start_index) ⇒ OtherPortion
Returns a new instance of OtherPortion.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/keisan/string_and_group_parser.rb', line 126 def initialize(expression, start_index) super(start_index) case expression[start_index] when STRING_CHARACTER_REGEX, OPEN_GROUP_REGEX, CLOSED_GROUP_REGEX raise Keisan::Exceptions::TokenizingError.new("Internal error, OtherPortion should not have string/braces at start") else index = start_index + 1 end while index < expression.size case expression[index] when STRING_CHARACTER_REGEX, OPEN_GROUP_REGEX, CLOSED_GROUP_REGEX, COMMENT_CHARACTER_REGEX break else index += 1 end end @end_index = index @string = expression[start_index...end_index] end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
124 125 126 |
# File 'lib/keisan/string_and_group_parser.rb', line 124 def string @string end |
Instance Method Details
#size ⇒ Object
149 150 151 |
# File 'lib/keisan/string_and_group_parser.rb', line 149 def size string.size end |
#to_s ⇒ Object
153 154 155 |
# File 'lib/keisan/string_and_group_parser.rb', line 153 def to_s string end |