Class: Lich::Gemstone::Gift
- Inherits:
-
Object
- Object
- Lich::Gemstone::Gift
- Defined in:
- lib/gemstone/gift.rb,
lib/games.rb
Overview
Gift class for tracking gift box status
Class Method Summary collapse
-
.ended ⇒ Integer
Ends the gift by setting the pulse count to 360.
-
.init_gift ⇒ Time, Integer
Returns the start time of the gift and the pulse count.
-
.load_serialized=(array) ⇒ void
Loads the serialized state of the gift from an array.
-
.pulse ⇒ Integer
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 ⇒ Time, Integer
Starts the gift timer and resets the pulse count.
-
.stopwatch ⇒ nil
Placeholder for a stopwatch method.
Class Method Details
.ended ⇒ Integer
Ends the gift by setting the pulse count to 360.
570 571 572 |
# File 'lib/games.rb', line 570 def Gift.ended @@pulse_count = 360 end |
.init_gift ⇒ Time, Integer
Returns the start time of the gift and the pulse count.
16 17 18 19 |
# File 'lib/gemstone/gift.rb', line 16 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.
562 563 564 565 |
# File 'lib/games.rb', line 562 def Gift.load_serialized=(array) @@gift_start = array[0] @@pulse_count = array[1].to_i end |
.pulse ⇒ Integer
Increments the pulse count by one.
533 534 535 |
# File 'lib/games.rb', line 533 def Gift.pulse @@pulse_count += 1 end |
.remaining ⇒ Float
Calculates the remaining time in seconds based on the pulse count.
540 541 542 |
# File 'lib/games.rb', line 540 def Gift.remaining ([360 - @@pulse_count, 0].max * 60).to_f end |
.restarts_on ⇒ Time
Calculates the time when the gift will restart.
547 548 549 |
# File 'lib/games.rb', line 547 def Gift.restarts_on @@gift_start + 594000 end |
.serialize ⇒ Array
Serializes the current state of the gift.
554 555 556 |
# File 'lib/games.rb', line 554 def Gift.serialize [@@gift_start, @@pulse_count] end |
.started ⇒ Time, Integer
Starts the gift timer and resets the pulse count.
525 526 527 528 |
# File 'lib/games.rb', line 525 def Gift.started @@gift_start = Time.now @@pulse_count = 0 end |
.stopwatch ⇒ nil
Placeholder for a stopwatch method.
577 578 579 |
# File 'lib/games.rb', line 577 def Gift.stopwatch nil end |