Class: Jaina::Parser::Tokenizer::TokenBuilder Private
- Inherits:
-
Object
- Object
- Jaina::Parser::Tokenizer::TokenBuilder
- Defined in:
- lib/jaina/parser/tokenizer/token_builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: ArgumentTypeCaster
Constant Summary collapse
- PARTS_SPLITTER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/[^,\[\]]+|\[|\]+/.freeze
- OPENING_ATTRIBUTE_GROUP_SYMBOL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'['
- CLOSING_ATTRIBUTE_GROUP_SYMBOL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
']'
- Error =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Class.new(StandardError)
- IncorrectTokenDefinitionError =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Class.new(Error)
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Jaina::Parser::Tokenizer::Token private
- #initialize(raw_token) ⇒ void constructor private
Constructor Details
#initialize(raw_token) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 |
# File 'lib/jaina/parser/tokenizer/token_builder.rb', line 47 def initialize(raw_token) @raw_token = raw_token @parts = raw_token.scan(PARTS_SPLITTER) end |
Class Method Details
.build(raw_token) ⇒ Jaina::Parser::Tokenizer::Token
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/jaina/parser/tokenizer/token_builder.rb', line 37 def build(raw_token) new(raw_token).build end |
Instance Method Details
#build ⇒ Jaina::Parser::Tokenizer::Token
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/jaina/parser/tokenizer/token_builder.rb', line 56 def build check_for_correctness! # NOTE: # format: token [ attr1, attr2, attr3 ] # TOKEN => parts[0] # OPENING BRAKET => parts[1] # CLOSING BRAKET => parts[-1] # ARGUMENTS => parts[2..-2] token = parts[0] arguments = parts.count.zero? ? [] : parts[2..-2] arguments = ArgumentTypeCaster.cast(*arguments) Jaina::Parser::Tokenizer::Token.new(raw_token, token, *arguments) end |