Class: DatagroutConduit::GuidedSession

Inherits:
Object
  • Object
show all
Defined in:
lib/datagrout_conduit/client.rb

Overview

Wrapper around an active guided workflow session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, state) ⇒ GuidedSession

Returns a new instance of GuidedSession.



492
493
494
495
# File 'lib/datagrout_conduit/client.rb', line 492

def initialize(client, state)
  @client = client
  @state = state
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



490
491
492
# File 'lib/datagrout_conduit/client.rb', line 490

def state
  @state
end

Instance Method Details

#choose(option_id) ⇒ Object

Make a choice and advance the workflow.



518
519
520
# File 'lib/datagrout_conduit/client.rb', line 518

def choose(option_id)
  @client.guide(session_id: session_id, choice: option_id.to_s)
end

#completeObject

Check if the workflow is completed and return the result.

Raises:



523
524
525
526
527
528
529
# File 'lib/datagrout_conduit/client.rb', line 523

def complete
  if status == "completed" && result
    return result
  end

  raise Error, "Workflow not complete (status: #{status}). Call choose() with an option."
end

#optionsObject



505
506
507
# File 'lib/datagrout_conduit/client.rb', line 505

def options
  @state.options
end

#resultObject



509
510
511
# File 'lib/datagrout_conduit/client.rb', line 509

def result
  @state.result
end

#session_idObject



497
498
499
# File 'lib/datagrout_conduit/client.rb', line 497

def session_id
  @state.session_id
end

#statusObject



501
502
503
# File 'lib/datagrout_conduit/client.rb', line 501

def status
  @state.status
end

#stepObject



513
514
515
# File 'lib/datagrout_conduit/client.rb', line 513

def step
  @state.step
end