Sha256: 47d94645d3061bd8ac893f5d9565bf3898490f22bbce76cf07cfb3c7034024ed

Contents?: true

Size: 384 Bytes

Versions: 1

Compression:

Stored size: 384 Bytes

Contents

require 'delegate'

module SearchLingo
  class Token < DelegateClass(String)
    FORMAT = %r{\A(?:(\S+):\s*)?"?(.+?)"?\z}

    def operator
      self[FORMAT, 1]
    end

    def term
      self[FORMAT, 2]
    end

    def compound?
      !!operator
    end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
search_lingo-1.0.0.beta2 lib/search_lingo/token.rb