Class: PlaylyfeClient::V2::SetMetric
- Defined in:
- lib/playlyfe_client/v2/metric/set_metric.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Attributes inherited from Metric
#description, #id, #name, #type
Attributes inherited from Metric
Instance Method Summary collapse
Methods inherited from Metric
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/playlyfe_client/v2/metric/set_metric.rb', line 6 def items @items end |
Instance Method Details
#apply_reward(reward, scores) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/playlyfe_client/v2/metric/set_metric.rb', line 8 def apply_reward(reward, scores) reward[:value].each do |rwd_item| score_item=scores[:sets][self.id.to_sym].detect { |i| i[:name] == rwd_item[:name] } case reward[:verb] when "add" score_item[:count]+=rwd_item[:count].to_i when "remove" score_item[:count]-=rwd_item[:count].to_i when "set" score_item[:count]=rwd_item[:count].to_i end end end |