Class: Jaina::Parser::Tokenizer::TokenBuilder Private

Inherits:
Object
  • Object
show all
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.

Since:

  • 0.4.0

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.

Returns:

  • (Regexp)

Since:

  • 0.4.0

/[^,\[\]]+|\[|\]+/.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.

Returns:

  • (String)

Since:

  • 0.4.0

'['
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.

Returns:

  • (String)

Since:

  • 0.4.0

']'
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.

Since:

  • 0.4.0

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.

Since:

  • 0.4.0

Class.new(Error)

Class Method Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • raw_token (String)

Since:

  • 0.4.0



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.

Parameters:

  • raw_token (String)

Returns:

Since:

  • 0.4.0



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

#buildJaina::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.

Returns:

Since:

  • 0.4.0



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