Class: Refocus::Samples
- Inherits:
-
Object
- Object
- Refocus::Samples
- Includes:
- JsonHelper
- Defined in:
- lib/refocus/samples.rb,
lib/refocus/samples/collector.rb
Defined Under Namespace
Classes: Collector
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
Instance Method Summary collapse
- #collector ⇒ Object
- #get(subject:, aspect:) ⇒ Object
-
#initialize(url:, token:) ⇒ Samples
constructor
A new instance of Samples.
- #list(limit: nil) ⇒ Object
- #submit(name:, aspect:, value:) ⇒ Object
Methods included from JsonHelper
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
#http ⇒ Object (readonly)
Returns the value of attribute http.
8 9 10 |
# File 'lib/refocus/samples.rb', line 8 def http @http end |
Instance Method Details
#collector ⇒ Object
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 |