Sha256: 429496a44b73b2a0c6f66d2b4b7231e72aeb78d5be88852250bb8fd3d33cd1ff

Contents?: true

Size: 457 Bytes

Versions: 3

Compression:

Stored size: 457 Bytes

Contents

require 'delegate'
require 'search_lingo/constants'

module SearchLingo
  class Token < DelegateClass(String)
    STRUCTURE = /\A(?:(#{OPERATOR}):[[:space:]]*)?"?(.+?)"?\z/

    def operator
      self[STRUCTURE, 1]
    end

    def term
      self[STRUCTURE, 2]
    end

    def compound?
      !!operator
    end

    def inspect
      '#<%s String(%s) operator=%s term=%s>' %
        [self.class, super, operator.inspect, term.inspect]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
search_lingo-1.0.1 lib/search_lingo/token.rb
search_lingo-1.0.0 lib/search_lingo/token.rb
search_lingo-1.0.0.beta3 lib/search_lingo/token.rb