class Keisan::StringAndGroupParser::OtherPortion

Attributes

string[R]

Public Class Methods

new(expression, start_index) click to toggle source
# 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

Public Instance Methods

size() click to toggle source
# File lib/keisan/string_and_group_parser.rb, line 149
def size
  string.size
end
to_s() click to toggle source
# File lib/keisan/string_and_group_parser.rb, line 153
def to_s
  string
end