Class: ClickHouse::Ast::Parser
- Inherits:
-
Object
- Object
- ClickHouse::Ast::Parser
- Defined in:
- lib/click_house/ast/parser.rb
Constant Summary collapse
- OPEN =
'('
- CLOSED =
')'
- COMMA =
','
- SPACE =
' '
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(input) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Object
Map(String, Decimal(10, 5)) Array(Array(Array(Array(Nullable(Int, String))))).
Constructor Details
#initialize(input) ⇒ Parser
Returns a new instance of Parser.
16 17 18 |
# File 'lib/click_house/ast/parser.rb', line 16 def initialize(input) @input = input end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
13 14 15 |
# File 'lib/click_house/ast/parser.rb', line 13 def input @input end |
Instance Method Details
#parse ⇒ Object
Map(String, Decimal(10, 5)) Array(Array(Array(Array(Nullable(Int, String)))))
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/click_house/ast/parser.rb', line 23 def parse ticker = Ticker.new control = false input.each_char do |char| # cases like (1,<space after comma> 3) next if control && char == SPACE case char when OPEN control = true ticker.open when CLOSED control = true ticker.close when COMMA control = true ticker.comma else control = false ticker.char(char) end end # if a single type like "Int" ticker.current.name! unless control ticker.current end |