Class: AkamaiApi::ECCU::Tokenizer
- Inherits:
-
Object
- Object
- AkamaiApi::ECCU::Tokenizer
- Defined in:
- lib/akamai_api/eccu/tokenizer.rb
Overview
Class used to tokenize path used for invalidate cache
foo/bar/*.txt
Constant Summary collapse
- SEPARATORS =
['/']
- DIR_REGEXP =
/^[^\/]+$/
- WILDCARD_REGEXP =
/^\**$/
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #current_token ⇒ Object
-
#initialize(expression) ⇒ Tokenizer
constructor
A new instance of Tokenizer.
- #look_next_token(i = 1) ⇒ Object
- #look_next_token_except(exclude_type = nil) ⇒ Object
- #look_next_token_of_type(token_type = nil) ⇒ Object
- #look_prev_token(i = 1) ⇒ Object
- #next_token ⇒ Object
Constructor Details
#initialize(expression) ⇒ Tokenizer
Returns a new instance of Tokenizer.
15 16 17 18 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 15 def initialize expression @cursor = -1 tokenize expression end |
Instance Attribute Details
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
13 14 15 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 13 def cursor @cursor end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
13 14 15 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 13 def tokens @tokens end |
Instance Method Details
#current_token ⇒ Object
20 21 22 23 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 20 def current_token return nil if cursor == -1 tokens[cursor] end |
#look_next_token(i = 1) ⇒ Object
30 31 32 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 30 def look_next_token i = 1 tokens[cursor + i] end |
#look_next_token_except(exclude_type = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 38 def look_next_token_except exclude_type = nil look_next_token if exclude_type == nil i = 1 while tokens[cursor + i].type == exclude_type i += 1 end tokens[cursor + i] end |
#look_next_token_of_type(token_type = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 48 def look_next_token_of_type token_type = nil look_next_token if token_type == nil i = cursor while tokens.size < i return tokens[i] if tokens[i].type == token_type i += 1 end nil end |
#look_prev_token(i = 1) ⇒ Object
34 35 36 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 34 def look_prev_token i = 1 tokens[cursor - 1] end |
#next_token ⇒ Object
25 26 27 28 |
# File 'lib/akamai_api/eccu/tokenizer.rb', line 25 def next_token @cursor += 1 current_token end |