Class: CloudWatchLogsInsightsUrlBuilder::Criteria

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudwatch_logs_insights_url_builder/criteria.rb

Instance Method Summary collapse

Constructor Details

#initializeCriteria

Returns a new instance of Criteria.



3
4
5
# File 'lib/cloudwatch_logs_insights_url_builder/criteria.rb', line 3

def initialize
  @conditions = []
end

Instance Method Details

#add(key, value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cloudwatch_logs_insights_url_builder/criteria.rb', line 7

def add(key, value)
  case value
  when Array
    result = +encode("~#{key}~(")

    value.each do |v|
      result << "#{encode("~'")}#{encode_value(v)}"
    end

    @conditions << result + encode(')')

  when String
    @conditions << "#{encode("~#{key}~'")}#{encode_value(value)}"
  else
    @conditions << "#{encode("~#{key}~")}#{encode_value(value)}"
  end
end

#buildObject



25
26
27
# File 'lib/cloudwatch_logs_insights_url_builder/criteria.rb', line 25

def build
  "#{encode('~(')}#{@conditions.join.delete_prefix(encode('~'))}#{encode(')')}"
end