class TinCanApi::Result
Result
Model class
Attributes
completion[RW]
duration[RW]
extensions[RW]
response[RW]
score[RW]
success[RW]
Public Class Methods
new(options={}, &block)
click to toggle source
# File lib/tin_can_api/result.rb, line 9 def initialize(options={}, &block) json = options.fetch(:json, nil) if json attributes = JSON.parse(json) self.score = TinCanApi::Score.new(json: attributes['score'].to_json) if attributes['score'] self.success = attributes['success'] if attributes['success'] self.completion = attributes['completion'] if attributes['completion'] self.duration = Duration.new(attributes['duration']) if attributes['duration'] self.response = attributes['response'] if attributes['response'] self.extensions = attributes['extensions'] if attributes['extensions'] else self.score = options.fetch(:score, nil) self.success = options.fetch(:success, nil) self.completion = options.fetch(:completion, nil) self.duration = options.fetch(:duration, nil) self.response = options.fetch(:response, nil) self.extensions = options.fetch(:extensions, nil) if block_given? block[self] end end end
Public Instance Methods
serialize(version)
click to toggle source
# File lib/tin_can_api/result.rb, line 33 def serialize(version) node = {} node['score'] = score.serialize(version) if score node['success'] = success if success node['completion'] = completion if completion node['duration'] = duration.iso8601 if duration node['response'] = response if response node['extensions'] = extensions if extensions node end