Class: Bpfql::Query::FilterOption

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lhs, op = nil, rhs = nil) ⇒ FilterOption

Returns a new instance of FilterOption.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/bpfql/query.rb', line 79

def initialize(lhs, op=nil, rhs=nil)
  if !rhs # args.size < 3
    m = /^([^\s]+)\s+([^\s]+)\s+([^\s]+|"[^"]+"|'[^']+')$/.match(lhs)
    unless m
      raise "Failed to parse where clause: #{lhs}"
    end
    if m2 = /^['"](.+)['"]$/.match(m[3])
      rhs = m2[1]
    else
      rhs = m[3]
    end
    super(m[1], m[2].to_sym, rhs)
  else
    super(lhs, op.to_sym, rhs)
  end
end

Instance Attribute Details

#lhsObject

Returns the value of attribute lhs

Returns:

  • (Object)

    the current value of lhs



71
72
73
# File 'lib/bpfql/query.rb', line 71

def lhs
  @lhs
end

#opObject

Returns the value of attribute op

Returns:

  • (Object)

    the current value of op



71
72
73
# File 'lib/bpfql/query.rb', line 71

def op
  @op
end

#rhsObject

Returns the value of attribute rhs

Returns:

  • (Object)

    the current value of rhs



71
72
73
# File 'lib/bpfql/query.rb', line 71

def rhs
  @rhs
end

Class Method Details

.parse(where) ⇒ Object



72
73
74
75
76
77
# File 'lib/bpfql/query.rb', line 72

def self.parse(where)
  where_list = Array(where)
  where_list.map do |whr|
    FilterOption.new(*whr)
  end
end