Sha256: fcd9f4eb2e803abbd4df32258c64ade40557fbaa272bee5a72740db8e39bc959

Contents?: true

Size: 461 Bytes

Versions: 1

Compression:

Stored size: 461 Bytes

Contents

# frozen_string_literal: true

require "forwardable"
require "json"

module Ollama
  class Response
    extend Forwardable
    def_delegators :@http_response, :code, :body

    def initialize(http_response)
      @http_response = http_response
    end

    def ok?
      code == "200"
    end

    def error?
      !ok?
    end

    def result=(value)
      @result = value
    end

    def result
      @result ||= JSON.parse(body) rescue {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ollama-rb-0.1.0 lib/ollama/response.rb