Class: CF::GoldStandard
- Inherits:
-
Object
- Object
- CF::GoldStandard
- Includes:
- Client
- Defined in:
- lib/cf/gold_standard.rb
Instance Attribute Summary collapse
-
#assignment_duration ⇒ Object
assignment_duration is the time period that is allocated for the badge test.
-
#errors ⇒ Object
Contains error message.
-
#expected_output ⇒ Object
ExpectedOutput of the gold-standard with which the actual output is matched.
-
#input ⇒ Object
the input provided to the goldstandard.
-
#name ⇒ Object
GoldStandard name.
-
#settings ⇒ Object
goldstandard settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GoldStandard
constructor
Initializes a new gold standard ===Usage Example: CF::GoldStandard.new({ :line => line,:name => “easy”,:input => [=>“”],:expected_output => [=> {“value” => “John”, “last_name” => => “Lennon”, “company” => => “Sprout”}]}) line.gold_standards gold_standard.
Constructor Details
#initialize(options = {}) ⇒ GoldStandard
Initializes a new gold standard
Usage Example:
CF::GoldStandard.new({ :line => line,:name => “easy”,:input => [=>“”],:expected_output => [=> {“value” => “John”, “last_name” => => “Lennon”, “company” => => “Sprout”}]}) line.gold_standards gold_standard
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cf/gold_standard.rb', line 30 def initialize(={}) @settings = @station = [:station] if [:station].present? @line = [:line] if [:line].nil? ? nil : [:line] if !@line.nil? || @station .delete(:station) if @settings[:station].present? .delete(:line) # for bulk_gold_standard if [:file] || ["file"] .symbolize_keys! file_upload = File.new([:file], 'rb') if @station # becuase of timeout issue we set and execute request like this # now it should handle upto 1000 gs easily request = RestClient::Request.new(:method => 'post', :url =>"#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@line.title.downcase}/stations/#{@station.index}/gold_standards.json", :payload => {:api_key => CF.api_key, :file => file_upload,:template => [:template]}, :accept => 'json', :timeout => 30000) resp = request.execute @station.gold_standards = self else resp = self.class.post("/lines/#{CF.account_name}/#{@line.title.downcase}/gold_standards.json", {:file => file_upload,:template => [:template]}) @line.gold_standards = self end #self.errors = resp['error']['message'] if resp["code"] != 200 else request = { :body => { :api_key => CF.api_key, :gold_standard => } } if @station resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@line.title.downcase}/stations/#{@station.index}/gold_standards.json",request) @station.gold_standards = self else resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{@line.title.downcase}/gold_standards.json",request) @line.gold_standards = self end self.errors = resp.parsed_response['error']['message'] if resp.code != 200 end end end |
Instance Attribute Details
#assignment_duration ⇒ Object
assignment_duration is the time period that is allocated for the badge test
19 20 21 |
# File 'lib/cf/gold_standard.rb', line 19 def assignment_duration @assignment_duration end |
#errors ⇒ Object
Contains error message
22 23 24 |
# File 'lib/cf/gold_standard.rb', line 22 def errors @errors end |
#expected_output ⇒ Object
ExpectedOutput of the gold-standard with which the actual output is matched
16 17 18 |
# File 'lib/cf/gold_standard.rb', line 16 def expected_output @expected_output end |
#input ⇒ Object
the input provided to the goldstandard
13 14 15 |
# File 'lib/cf/gold_standard.rb', line 13 def input @input end |
#name ⇒ Object
GoldStandard name
10 11 12 |
# File 'lib/cf/gold_standard.rb', line 10 def name @name end |
#settings ⇒ Object
goldstandard settings
7 8 9 |
# File 'lib/cf/gold_standard.rb', line 7 def settings @settings end |
Class Method Details
.create(*args) ⇒ Object
74 75 76 |
# File 'lib/cf/gold_standard.rb', line 74 def self.create(*args) GoldStandard.new(args.first) end |