Class: Cucumber::CucumberExpressions::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, text, start, _end) ⇒ Token

Returns a new instance of Token.



75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 75

def initialize(type, text, start, _end)
  @type, @text, @start, @end = type, text, start, _end
end

Class Method Details

.can_escape(codepoint) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/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) ⇒ Object



95
96
97
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 95

def self.is_escape_character(codepoint)
  codepoint.chr(Encoding::UTF_8) == ESCAPE_CHARACTER
end

.purpose_of(token) ⇒ Object



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/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) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/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) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/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

Instance Method Details

#endObject



91
92
93
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 91

def end
  @end
end

#startObject



87
88
89
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 87

def start
  @start
end

#textObject



83
84
85
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 83

def text
  @text
end

#to_hashObject



179
180
181
182
183
184
185
186
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 179

def to_hash
  {
      "type" => @type,
      "text" => @text,
      "start" => @start,
      "end" => @end
  }
end

#typeObject



79
80
81
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-cucumber-expressions-15.2.0/lib/cucumber/cucumber_expressions/ast.rb', line 79

def type
  @type
end