Class: Refocus::Samples

Inherits:
Object
  • Object
show all
Includes:
JsonHelper
Defined in:
lib/refocus/samples.rb,
lib/refocus/samples/collector.rb

Defined Under Namespace

Classes: Collector

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from JsonHelper

#json

Constructor Details

#initialize(url:, token:) ⇒ Samples

Returns a new instance of Samples.



10
11
12
# File 'lib/refocus/samples.rb', line 10

def initialize(url:, token:)
  @http = Refocus::Http.new(url: url, token: token)
end

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



8
9
10
# File 'lib/refocus/samples.rb', line 8

def http
  @http
end

Instance Method Details

#collectorObject



14
15
16
# File 'lib/refocus/samples.rb', line 14

def collector
  Collector.new(http: http)
end

#get(subject:, aspect:) ⇒ Object



30
31
32
# File 'lib/refocus/samples.rb', line 30

def get(subject:, aspect:)
  json(http.get(URI.escape("#{subject}\|#{aspect}")))
end

#list(limit: nil) ⇒ Object



24
25
26
27
28
# File 'lib/refocus/samples.rb', line 24

def list(limit: nil)
  params = ""
  params = params + "?limit=#{limit}" if limit
  json(http.get(params))
end

#submit(name:, aspect:, value:) ⇒ Object



18
19
20
21
22
# File 'lib/refocus/samples.rb', line 18

def submit(name:, aspect:, value:)
  c = collector
  c.add(name: name, aspect: aspect, value: value)
  c.submit
end