Class: Bpfql::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/bpfql/query.rb

Defined Under Namespace

Classes: FilterOption, ProbeOption, SelectOption, StopOption

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&b) ⇒ Query

Returns a new instance of Query.



23
24
25
# File 'lib/bpfql/query.rb', line 23

def initialize(&b)
  b.call(self) if b
end

Instance Attribute Details

#fromObject Also known as: probe

Returns the value of attribute from.



26
27
28
# File 'lib/bpfql/query.rb', line 26

def from
  @from
end

#group_byObject

Returns the value of attribute group_by.



26
27
28
# File 'lib/bpfql/query.rb', line 26

def group_by
  @group_by
end

#intervalObject

Returns the value of attribute interval.



26
27
28
# File 'lib/bpfql/query.rb', line 26

def interval
  @interval
end

#selectObject

Returns the value of attribute select.



26
27
28
# File 'lib/bpfql/query.rb', line 26

def select
  @select
end

#stopObject

Returns the value of attribute stop.



26
27
28
# File 'lib/bpfql/query.rb', line 26

def stop
  @stop
end

#whereObject

Returns the value of attribute where.



26
27
28
# File 'lib/bpfql/query.rb', line 26

def where
  @where
end

Class Method Details

.parse_yaml(yaml) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bpfql/query.rb', line 5

def self.parse_yaml(yaml)
  data = YAML.load(yaml)
  data['BPFQL'].map do |query|
    Query.new do |builder|
      builder.select = SelectOption.new(query['select'])
      builder.from = ProbeOption.new(query['from'])
      if query['where']
        builder.where = FilterOption.parse(query['where'])
      end
      builder.group_by = query['group_by'] # Accepts nil
      builder.interval = query['interval'] # Accepts nil
      if query['stop_after']
        builder.stop = StopOption.new(:after, query['stop_after'])
      end
    end
  end
end