Sha256: 24d18415f75d3f7ea45f7d23122741958cb93331e6bb7ff14ff66b8bcd31111b

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

module Evertils
  module Helper
    class SearchGrammar
      def from(conf)
        @configuration = conf
        @grammar = []

        fix_standard_grammar
        fix_tags if @configuration.include?(:tags)

        @grammar.join(' ')
      end

      private

      def fix_tags
        @configuration[:tags].each_pair do |k, v|
          @grammar.push("tag:#{k}-#{v}")
        end
      end

      def fix_standard_grammar
        @configuration.each_pair do |k, v|
          @grammar.push("#{k}:#{v}") unless k == :tags
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evertils-1.0.11 lib/evertils/helpers/search-grammar.rb