Class: Exa::Resources::ResearchTask

Inherits:
Struct
  • Object
show all
Defined in:
lib/exa/resources/research_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(research_id:, created_at:, status:, instructions:, model: nil, output_schema: nil, events: nil, output: nil, cost_dollars: nil, finished_at: nil, error: nil) ⇒ ResearchTask

Returns a new instance of ResearchTask.



8
9
10
11
# File 'lib/exa/resources/research_task.rb', line 8

def initialize(research_id:, created_at:, status:, instructions:, model: nil, output_schema: nil, events: nil, output: nil, cost_dollars: nil, finished_at: nil, error: nil)
  super
  freeze
end

Instance Attribute Details

#cost_dollarsObject

Returns the value of attribute cost_dollars

Returns:

  • (Object)

    the current value of cost_dollars



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def cost_dollars
  @cost_dollars
end

#created_atObject

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def created_at
  @created_at
end

#errorObject

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def error
  @error
end

#eventsObject

Returns the value of attribute events

Returns:

  • (Object)

    the current value of events



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def events
  @events
end

#finished_atObject

Returns the value of attribute finished_at

Returns:

  • (Object)

    the current value of finished_at



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def finished_at
  @finished_at
end

#instructionsObject

Returns the value of attribute instructions

Returns:

  • (Object)

    the current value of instructions



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def instructions
  @instructions
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def model
  @model
end

#outputObject

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def output
  @output
end

#output_schemaObject

Returns the value of attribute output_schema

Returns:

  • (Object)

    the current value of output_schema



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def output_schema
  @output_schema
end

#research_idObject

Returns the value of attribute research_id

Returns:

  • (Object)

    the current value of research_id



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def research_id
  @research_id
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



3
4
5
# File 'lib/exa/resources/research_task.rb', line 3

def status
  @status
end

Instance Method Details

#canceled?Boolean

Returns:

  • (Boolean)


17
# File 'lib/exa/resources/research_task.rb', line 17

def canceled? = status == 'canceled'

#completed?Boolean

Returns:

  • (Boolean)


15
# File 'lib/exa/resources/research_task.rb', line 15

def completed? = status == 'completed'

#failed?Boolean

Returns:

  • (Boolean)


16
# File 'lib/exa/resources/research_task.rb', line 16

def failed? = status == 'failed'

#finished?Boolean

Returns:

  • (Boolean)


19
# File 'lib/exa/resources/research_task.rb', line 19

def finished? = !running? && !pending?

#pending?Boolean

Returns:

  • (Boolean)


13
# File 'lib/exa/resources/research_task.rb', line 13

def pending? = status == 'pending'

#running?Boolean

Returns:

  • (Boolean)


14
# File 'lib/exa/resources/research_task.rb', line 14

def running? = status == 'running'

#to_hObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/exa/resources/research_task.rb', line 21

def to_h
  result = {
    research_id: research_id,
    created_at: created_at,
    status: status,
    instructions: instructions
  }
  result[:model] = model if model
  result[:output_schema] = output_schema if output_schema
  result[:events] = events if events
  result[:output] = output if output
  result[:cost_dollars] = cost_dollars if cost_dollars
  result[:finished_at] = finished_at if finished_at
  result[:error] = error if error
  result
end