Class: FactoryBotProfile::Stat
- Inherits:
-
Object
- Object
- FactoryBotProfile::Stat
- Defined in:
- lib/factory_bot_profile/stat.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#total_time ⇒ Object
readonly
Returns the value of attribute total_time.
Instance Method Summary collapse
- #average_time ⇒ Object
-
#initialize(name) ⇒ Stat
constructor
A new instance of Stat.
- #merge!(other) ⇒ Object
Constructor Details
#initialize(name) ⇒ Stat
Returns a new instance of Stat.
5 6 7 8 9 |
# File 'lib/factory_bot_profile/stat.rb', line 5 def initialize(name) @name = name @count = 0 @total_time = 0 end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
3 4 5 |
# File 'lib/factory_bot_profile/stat.rb', line 3 def count @count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/factory_bot_profile/stat.rb', line 3 def name @name end |
#total_time ⇒ Object (readonly)
Returns the value of attribute total_time.
3 4 5 |
# File 'lib/factory_bot_profile/stat.rb', line 3 def total_time @total_time end |
Instance Method Details
#average_time ⇒ Object
11 12 13 |
# File 'lib/factory_bot_profile/stat.rb', line 11 def average_time total_time / count end |
#merge!(other) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/factory_bot_profile/stat.rb', line 15 def merge!(other) raise "attempting to merge unrelated stats" if name != other.name @count += other.count @total_time += other.total_time end |