Sha256: 7b28c80c6e77e146ffd879b05e037859c5e977b27f8daa04ee73c974cc4cbf51

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# Literal Node of AST (Abstract Syntax Tree)
require 'time'

module Fluent
  module FilterWhere
    class Parser
      class Literal
        attr_reader :text
        attr_reader :val

        def get(record)
          @val
        end
      end

      class BooleanLiteral < Literal
        def initialize(text)
          @text = text
          if text.downcase == 'true'.freeze
            @val = true
          elsif text.downcase == 'false'.freeze
            @val = false
          else
            raise ConfigError.new("\"%s\" is not a Boolean literal" % text)
          end
        end
      end

      class NumberLiteral < Literal
        def initialize(text)
          @text = text
          @val = Float(text)
        end
      end

      class StringLiteral < Literal
        def initialize(text)
          @text = text
          @val = text
        end
      end

      class IdentifierLiteral < Literal
        attr_reader :name

        def initialize(name)
          @name = name
        end

        def get(record)
          record[@name]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-filter_where-1.0.1 lib/fluent/plugin/filter_where/parser/literal.rb
fluent-plugin-filter_where-1.0.0 lib/fluent/plugin/filter_where/parser/literal.rb