Class: CloudWatchLogsInsightsUrlBuilder::Criteria
- Inherits:
-
Object
- Object
- CloudWatchLogsInsightsUrlBuilder::Criteria
- Defined in:
- lib/cloudwatch_logs_insights_url_builder/criteria.rb
Instance Method Summary collapse
- #add(key, value) ⇒ Object
- #build ⇒ Object
-
#initialize ⇒ Criteria
constructor
A new instance of Criteria.
Constructor Details
#initialize ⇒ Criteria
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 |
#build ⇒ Object
25 26 27 |
# File 'lib/cloudwatch_logs_insights_url_builder/criteria.rb', line 25 def build "#{encode('~(')}#{@conditions.join.delete_prefix(encode('~'))}#{encode(')')}" end |