Class: TinCanApi::Score
- Inherits:
-
Object
- Object
- TinCanApi::Score
- Defined in:
- lib/tin_can_api/score.rb
Overview
Score model class
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#scaled ⇒ Object
Returns the value of attribute scaled.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Score
constructor
A new instance of Score.
- #serialize(version) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Score
Returns a new instance of Score.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tin_can_api/score.rb', line 8 def initialize(={}, &block) json = .fetch(:json, nil) if json attributes = JSON.parse(json) self.scaled = attributes['scaled'] if attributes['scaled'] self.raw = attributes['raw'] if attributes['raw'] self.min = attributes['min'] if attributes['min'] self.max = attributes['max'] if attributes['max'] else self.scaled = .fetch(:scaled, nil) self.raw = .fetch(:raw, nil) self.min = .fetch(:min, nil) self.max = .fetch(:max, nil) if block_given? block[self] end end end |
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
6 7 8 |
# File 'lib/tin_can_api/score.rb', line 6 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
6 7 8 |
# File 'lib/tin_can_api/score.rb', line 6 def min @min end |
#raw ⇒ Object
Returns the value of attribute raw.
6 7 8 |
# File 'lib/tin_can_api/score.rb', line 6 def raw @raw end |
#scaled ⇒ Object
Returns the value of attribute scaled.
6 7 8 |
# File 'lib/tin_can_api/score.rb', line 6 def scaled @scaled end |
Instance Method Details
#serialize(version) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/tin_can_api/score.rb', line 29 def serialize(version) node = {} node['scaled'] = scaled if scaled node['raw'] = raw if raw node['min'] = min if min node['max'] = max if max node end |