Class: Lich::Gemstone::Gift
- Inherits:
-
Object
- Object
- Lich::Gemstone::Gift
- Defined in:
- documented/gemstone/gift.rb
Overview
Gift class for tracking gift box status Gift class for tracking gift box status
This class manages the state of a gift box, including tracking the start time, pulse count, and calculating remaining time.
Class Attribute Summary collapse
-
.gift_start ⇒ Object
readonly
Returns the value of attribute gift_start.
-
.pulse_count ⇒ Object
readonly
Returns the value of attribute pulse_count.
Class Method Summary collapse
-
.ended ⇒ void
Marks the gift as ended by setting the pulse count to 360.
-
.init_gift ⇒ void
Initializes the gift tracking system.
-
.load_serialized=(array) ⇒ void
Loads the serialized state of the gift from an array.
-
.pulse ⇒ void
Increments the pulse count by one.
-
.remaining ⇒ Float
Calculates the remaining time in seconds based on the pulse count.
-
.restarts_on ⇒ Time
Calculates the time when the gift will restart.
-
.serialize ⇒ Array
Serializes the current state of the gift.
-
.started ⇒ void
Starts the gift tracking by resetting the start time and pulse count.
-
.stopwatch ⇒ nil
Placeholder method for stopwatch functionality.
Class Attribute Details
.gift_start ⇒ Object (readonly)
Returns the value of attribute gift_start.
14 15 16 |
# File 'documented/gemstone/gift.rb', line 14 def gift_start @gift_start end |
.pulse_count ⇒ Object (readonly)
Returns the value of attribute pulse_count.
14 15 16 |
# File 'documented/gemstone/gift.rb', line 14 def pulse_count @pulse_count end |
Class Method Details
.ended ⇒ void
This method returns an undefined value.
Marks the gift as ended by setting the pulse count to 360.
80 81 82 |
# File 'documented/gemstone/gift.rb', line 80 def ended @pulse_count = 360 end |
.init_gift ⇒ void
This method returns an undefined value.
Initializes the gift tracking system.
20 21 22 23 |
# File 'documented/gemstone/gift.rb', line 20 def init_gift @gift_start = Time.now @pulse_count = 0 end |
.load_serialized=(array) ⇒ void
This method returns an undefined value.
Loads the serialized state of the gift from an array.
71 72 73 74 |
# File 'documented/gemstone/gift.rb', line 71 def load_serialized=(array) @gift_start = array[0] @pulse_count = array[1].to_i end |
.pulse ⇒ void
This method returns an undefined value.
Increments the pulse count by one.
38 39 40 |
# File 'documented/gemstone/gift.rb', line 38 def pulse @pulse_count += 1 end |
.remaining ⇒ Float
Calculates the remaining time in seconds based on the pulse count.
46 47 48 |
# File 'documented/gemstone/gift.rb', line 46 def remaining ([360 - @pulse_count, 0].max * 60).to_f end |
.restarts_on ⇒ Time
Calculates the time when the gift will restart.
54 55 56 |
# File 'documented/gemstone/gift.rb', line 54 def restarts_on @gift_start + 594000 end |
.serialize ⇒ Array
Serializes the current state of the gift.
62 63 64 |
# File 'documented/gemstone/gift.rb', line 62 def serialize [@gift_start, @pulse_count] end |
.started ⇒ void
This method returns an undefined value.
Starts the gift tracking by resetting the start time and pulse count.
29 30 31 32 |
# File 'documented/gemstone/gift.rb', line 29 def started @gift_start = Time.now @pulse_count = 0 end |
.stopwatch ⇒ nil
Placeholder method for stopwatch functionality.
88 89 90 |
# File 'documented/gemstone/gift.rb', line 88 def stopwatch nil end |