Class: ClickHouse::SQL::Placeholder
- Inherits:
-
Struct
- Object
- Struct
- ClickHouse::SQL::Placeholder
- Defined in:
- lib/clickhouse/sql/placeholder.rb
Overview
A parsed {name}, {name:Type}, or anonymous {} placeholder from a
SQL fragment.
Instance Attribute Summary collapse
-
#begin_pos ⇒ Integer
Start offset in the source SQL.
-
#end_pos ⇒ Integer
End offset in the source SQL.
-
#name ⇒ String?
Placeholder name, or nil for anonymous
{}slots. -
#raw ⇒ String
The placeholder text including braces.
-
#type ⇒ String?
ClickHouse type text, or nil for fragment slots.
Instance Method Summary collapse
-
#anonymous? ⇒ Boolean
Returns whether this placeholder is an anonymous
{}fragment slot. -
#name_sym ⇒ Symbol?
Returns the placeholder name as a symbol.
-
#typed? ⇒ Boolean
Returns whether this placeholder is a ClickHouse typed value.
Instance Attribute Details
#begin_pos ⇒ Integer
Returns Start offset in the source SQL.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clickhouse/sql/placeholder.rb', line 18 Placeholder = Struct.new(:raw, :name, :type, :begin_pos, :end_pos, keyword_init: true) do # Returns whether this placeholder is a ClickHouse typed value. # # @return [Boolean] True for `{name:Type}`, false for fragment slots. def typed? !ValueNormalization.blank_string?(type) end # Returns whether this placeholder is an anonymous `{}` fragment slot. # # @return [Boolean] True for `{}`, false for named placeholders. def anonymous? name.nil? end # Returns the placeholder name as a symbol. # # @return [Symbol, nil] Symbolized placeholder name, or nil for anonymous slots. def name_sym name&.to_sym end end |
#end_pos ⇒ Integer
Returns End offset in the source SQL.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clickhouse/sql/placeholder.rb', line 18 Placeholder = Struct.new(:raw, :name, :type, :begin_pos, :end_pos, keyword_init: true) do # Returns whether this placeholder is a ClickHouse typed value. # # @return [Boolean] True for `{name:Type}`, false for fragment slots. def typed? !ValueNormalization.blank_string?(type) end # Returns whether this placeholder is an anonymous `{}` fragment slot. # # @return [Boolean] True for `{}`, false for named placeholders. def anonymous? name.nil? end # Returns the placeholder name as a symbol. # # @return [Symbol, nil] Symbolized placeholder name, or nil for anonymous slots. def name_sym name&.to_sym end end |
#name ⇒ String?
Returns Placeholder name, or nil for anonymous {} slots.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clickhouse/sql/placeholder.rb', line 18 Placeholder = Struct.new(:raw, :name, :type, :begin_pos, :end_pos, keyword_init: true) do # Returns whether this placeholder is a ClickHouse typed value. # # @return [Boolean] True for `{name:Type}`, false for fragment slots. def typed? !ValueNormalization.blank_string?(type) end # Returns whether this placeholder is an anonymous `{}` fragment slot. # # @return [Boolean] True for `{}`, false for named placeholders. def anonymous? name.nil? end # Returns the placeholder name as a symbol. # # @return [Symbol, nil] Symbolized placeholder name, or nil for anonymous slots. def name_sym name&.to_sym end end |
#raw ⇒ String
Returns The placeholder text including braces.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clickhouse/sql/placeholder.rb', line 18 Placeholder = Struct.new(:raw, :name, :type, :begin_pos, :end_pos, keyword_init: true) do # Returns whether this placeholder is a ClickHouse typed value. # # @return [Boolean] True for `{name:Type}`, false for fragment slots. def typed? !ValueNormalization.blank_string?(type) end # Returns whether this placeholder is an anonymous `{}` fragment slot. # # @return [Boolean] True for `{}`, false for named placeholders. def anonymous? name.nil? end # Returns the placeholder name as a symbol. # # @return [Symbol, nil] Symbolized placeholder name, or nil for anonymous slots. def name_sym name&.to_sym end end |
#type ⇒ String?
Returns ClickHouse type text, or nil for fragment slots.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clickhouse/sql/placeholder.rb', line 18 Placeholder = Struct.new(:raw, :name, :type, :begin_pos, :end_pos, keyword_init: true) do # Returns whether this placeholder is a ClickHouse typed value. # # @return [Boolean] True for `{name:Type}`, false for fragment slots. def typed? !ValueNormalization.blank_string?(type) end # Returns whether this placeholder is an anonymous `{}` fragment slot. # # @return [Boolean] True for `{}`, false for named placeholders. def anonymous? name.nil? end # Returns the placeholder name as a symbol. # # @return [Symbol, nil] Symbolized placeholder name, or nil for anonymous slots. def name_sym name&.to_sym end end |
Instance Method Details
#anonymous? ⇒ Boolean
Returns whether this placeholder is an anonymous {} fragment slot.
29 30 31 |
# File 'lib/clickhouse/sql/placeholder.rb', line 29 def anonymous? name.nil? end |
#name_sym ⇒ Symbol?
Returns the placeholder name as a symbol.
36 37 38 |
# File 'lib/clickhouse/sql/placeholder.rb', line 36 def name_sym name&.to_sym end |
#typed? ⇒ Boolean
Returns whether this placeholder is a ClickHouse typed value.
22 23 24 |
# File 'lib/clickhouse/sql/placeholder.rb', line 22 def typed? !ValueNormalization.blank_string?(type) end |