Class: Clarinet::Inputs

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/clarinet/inputs.rb

Instance Method Summary collapse

Instance Method Details

#[]Clarinet::Model

Returns:

See Also:

  • Array#[]


20
# File 'lib/clarinet/inputs.rb', line 20

delegate [:[], :each, :map, :find, :select, :reject] => :@inputs

#create(inputs) ⇒ Clarinet::Inputs

Adds an input or multiple inputs

Returns:



35
36
37
38
39
40
41
# File 'lib/clarinet/inputs.rb', line 35

def create(inputs)
  inputs = [inputs] unless inputs.is_a? Array
  inputs = inputs.map { |input| Clarinet::Utils.format_input(input) }

  data = @app.client.inputs_create inputs
  Clarinet::Inputs.new data[:inputs]
end

#delete(id) ⇒ Hash

Delete an input or a list of inputs by id

Returns:

  • (Hash)

    API response



45
46
47
48
# File 'lib/clarinet/inputs.rb', line 45

def delete(id)
  @app.client.input_delete id if id.is_a? String
  @app.client.inputs_delete id if id.is_a? Array
end

#delete_allHash

Delete all inputs

Returns:

  • (Hash)

    API response



52
53
54
# File 'lib/clarinet/inputs.rb', line 52

def delete_all
  @app.client.inputs_delete_all
end

#delete_concepts(inputs) ⇒ Object



88
89
90
# File 'lib/clarinet/inputs.rb', line 88

def delete_concepts(inputs)
  update 'remove', inputs
end

#eachObject

See Also:

  • Array#each


20
# File 'lib/clarinet/inputs.rb', line 20

delegate [:[], :each, :map, :find, :select, :reject] => :@inputs

#findObject

See Also:

  • Array#find


20
# File 'lib/clarinet/inputs.rb', line 20

delegate [:[], :each, :map, :find, :select, :reject] => :@inputs

#get(id) ⇒ Clarinet::Input

Get input by id

Parameters:

  • id (String)

    The input id

Returns:



69
70
71
72
# File 'lib/clarinet/inputs.rb', line 69

def get(id)
  data = @app.client.input id
  Clarinet::Input.new @app, data[:input]
end

#list(options = { page: 1, per_page: 20 }) ⇒ Clarinet::Inputs

Get all inputs in app

Parameters:

  • options (Hash) (defaults to: { page: 1, per_page: 20 })

    Listing options

Options Hash (options):

  • :page (Int) — default: 1

    The page number

  • :per_page (Int) — default: 20

    Number of models to return per page

Returns:



61
62
63
64
# File 'lib/clarinet/inputs.rb', line 61

def list(options = { page: 1, per_page: 20 })
  data = @app.client.inputs options
  Clarinet::Inputs.new @app, data[:inputs]
end

#mapObject

See Also:

  • Array#map


20
# File 'lib/clarinet/inputs.rb', line 20

delegate [:[], :each, :map, :find, :select, :reject] => :@inputs

#merge_concepts(inputs) ⇒ Object



80
81
82
# File 'lib/clarinet/inputs.rb', line 80

def merge_concepts(inputs)
  update 'merge', inputs
end

#overwrite_concepts(inputs) ⇒ Object



84
85
86
# File 'lib/clarinet/inputs.rb', line 84

def overwrite_concepts(inputs)
  update 'overwrite', inputs
end

#selectObject

See Also:

  • Array#select


20
# File 'lib/clarinet/inputs.rb', line 20

delegate [:[], :each, :map, :find, :select, :reject] => :@inputs

#statusHash

Get inputs status (number of uploaded, in process or failed inputs)

Returns:

  • (Hash)

    API response



76
77
78
# File 'lib/clarinet/inputs.rb', line 76

def status
  @app.client.inputs_status
end