Class: Achievements::Achievement

Inherits:
Object
  • Object
show all
Defined in:
lib/achievements/achievement.rb

Overview

Achievement, basis of counters

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, name, threshold) ⇒ Achievement

A method needs a context, name, and threshold, in that order.



11
12
13
14
15
# File 'lib/achievements/achievement.rb', line 11

def initialize(context, name, threshold)
  @context = context
  @name = name
  @threshold = threshold
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



7
8
9
# File 'lib/achievements/achievement.rb', line 7

def context
  @context
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/achievements/achievement.rb', line 5

def name
  @name
end

#thresholdObject

Returns the value of attribute threshold.



6
7
8
# File 'lib/achievements/achievement.rb', line 6

def threshold
  @threshold
end

Instance Method Details

#to_hashObject

Convenience to_hash method



18
19
20
# File 'lib/achievements/achievement.rb', line 18

def to_hash
  {:name => @name, :threshold => @threshold, :context => @context}
end