Sha256: 95b01c34aed05b19ec78c29d961fafb4be574e6ebd8c917d804cf11d78291cab

Contents?: true

Size: 425 Bytes

Versions: 7

Compression:

Stored size: 425 Bytes

Contents

require 'json'
module Inquisitio
  class Document

    attr_reader :type, :id, :version, :fields
    def initialize(type, id, version, fields)
      @type = type
      @id = id
      @version = version
      @fields = fields.reject {|k,v| v.nil?}
    end

    def to_SDF
      <<-EOS
{ "type": "#{type}",
  "id":   "#{id}",
  "version": #{version},
  "lang": "en",
  "fields": #{fields.to_json}
}
      EOS
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
inquisitio-1.1.2 lib/inquisitio/document.rb
inquisitio-1.1.1 lib/inquisitio/document.rb
inquisitio-1.1.0 lib/inquisitio/document.rb
inquisitio-1.0.0 lib/inquisitio/document.rb
inquisitio-0.2.0 lib/inquisitio/document.rb
inquisitio-0.1.7 lib/inquisitio/document.rb
inquisitio-0.1.6 lib/inquisitio/document.rb