Class: Shiba::Parsers::PostgresExplainIndexConditions

Inherits:
Object
  • Object
show all
Defined in:
lib/shiba/parsers/postgres_explain_index_conditions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ PostgresExplainIndexConditions

Returns a new instance of PostgresExplainIndexConditions.



7
8
9
10
11
# File 'lib/shiba/parsers/postgres_explain_index_conditions.rb', line 7

def initialize(string)
  @string = string
  @sc = ShibaStringScanner.new(string)
  @fields = nil
end

Instance Attribute Details

#scObject (readonly)

Returns the value of attribute sc.



13
14
15
# File 'lib/shiba/parsers/postgres_explain_index_conditions.rb', line 13

def sc
  @sc
end

Instance Method Details

#fieldsObject



30
31
32
33
# File 'lib/shiba/parsers/postgres_explain_index_conditions.rb', line 30

def fields
  parse!
  @fields[nil]
end

#join_fieldsObject



35
36
37
38
# File 'lib/shiba/parsers/postgres_explain_index_conditions.rb', line 35

def join_fields
  parse!
  @fields
end

#parse!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shiba/parsers/postgres_explain_index_conditions.rb', line 14

def parse!
  return if @fields
  @fields = {}
  sc.scan(LPAREN)
  if sc.peek(1) == "(" && !sc.match?(/\(\w+\)::/)

    while sc.peek(1) == "("
      sc.getch
      extract_field(sc)
      sc.scan(/\s+AND\s+/)
    end
  else
    extract_field(sc)
  end
end