class Cucumber::CucumberExpressions::Token

Public Class Methods

can_escape(codepoint) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 99
def self.can_escape(codepoint)
  c = codepoint.chr(Encoding::UTF_8)
  if c == ' '
    # TODO: Unicode whitespace?
    return true
  end
  case c
  when ESCAPE_CHARACTER
    true
  when ALTERNATION_CHARACTER
    true
  when BEGIN_PARAMETER_CHARACTER
    true
  when END_PARAMETER_CHARACTER
    true
  when BEGIN_OPTIONAL_CHARACTER
    true
  when END_OPTIONAL_CHARACTER
    true
  else
    false
  end
end
is_escape_character(codepoint) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 95
def self.is_escape_character(codepoint)
  codepoint.chr(Encoding::UTF_8) == ESCAPE_CHARACTER
end
new(type, text, start, _end) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 75
def initialize(type, text, start, _end)
  @type, @text, @start, @end = type, text, start, _end
end
purpose_of(token) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 162
def self.purpose_of(token)
  case token
  when TokenType::BEGIN_OPTIONAL
    return 'optional text'
  when TokenType::END_OPTIONAL
    return 'optional text'
  when TokenType::BEGIN_PARAMETER
    return 'a parameter'
  when TokenType::END_PARAMETER
    return 'a parameter'
  when TokenType::ALTERNATION
    return 'alternation'
  else
    return ''
  end
end
symbol_of(token) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 145
def self.symbol_of(token)
  case token
  when TokenType::BEGIN_OPTIONAL
    return BEGIN_OPTIONAL_CHARACTER
  when TokenType::END_OPTIONAL
    return END_OPTIONAL_CHARACTER
  when TokenType::BEGIN_PARAMETER
    return BEGIN_PARAMETER_CHARACTER
  when TokenType::END_PARAMETER
    return END_PARAMETER_CHARACTER
  when TokenType::ALTERNATION
    return ALTERNATION_CHARACTER
  else
    return ''
  end
end
type_of(codepoint) click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 123
def self.type_of(codepoint)
  c = codepoint.chr(Encoding::UTF_8)
  if c == ' '
    # TODO: Unicode whitespace?
    return TokenType::WHITE_SPACE
  end
  case c
  when ALTERNATION_CHARACTER
    TokenType::ALTERNATION
  when BEGIN_PARAMETER_CHARACTER
    TokenType::BEGIN_PARAMETER
  when END_PARAMETER_CHARACTER
    TokenType::END_PARAMETER
  when BEGIN_OPTIONAL_CHARACTER
    TokenType::BEGIN_OPTIONAL
  when END_OPTIONAL_CHARACTER
    TokenType::END_OPTIONAL
  else
    TokenType::TEXT
  end
end

Public Instance Methods

end() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 91
def end
  @end
end
start() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 87
def start
  @start
end
text() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 83
def text
  @text
end
to_hash() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 179
def to_hash
  {
      "type" => @type,
      "text" => @text,
      "start" => @start,
      "end" => @end
  }
end
type() click to toggle source
# File lib/cucumber/cucumber_expressions/ast.rb, line 79
def type
  @type
end