Class: Lich::Gemstone::Gift

Inherits:
Object
  • Object
show all
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.

Examples:

Initializing a gift

Lich::Gemstone::Gift.init_gift

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.gift_startObject (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_countObject (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

.endedvoid

This method returns an undefined value.

Marks the gift as ended by setting the pulse count to 360.

Examples:

Ending the gift tracking

Lich::Gemstone::Gift.ended


80
81
82
# File 'documented/gemstone/gift.rb', line 80

def ended
  @pulse_count = 360
end

.init_giftvoid

This method returns an undefined value.

Initializes the gift tracking system.

Examples:

Initializing the gift system

Lich::Gemstone::Gift.init_gift


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.

Examples:

Loading serialized data

Lich::Gemstone::Gift.load_serialized = [Time.now, 5]

Parameters:

  • array (Array)

    An array containing the gift start time and pulse count.



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

.pulsevoid

This method returns an undefined value.

Increments the pulse count by one.

Examples:

Incrementing the pulse count

Lich::Gemstone::Gift.pulse


38
39
40
# File 'documented/gemstone/gift.rb', line 38

def pulse
  @pulse_count += 1
end

.remainingFloat

Calculates the remaining time in seconds based on the pulse count.

Examples:

Getting remaining time

remaining_time = Lich::Gemstone::Gift.remaining

Returns:

  • (Float)

    The remaining time in seconds.



46
47
48
# File 'documented/gemstone/gift.rb', line 46

def remaining
  ([360 - @pulse_count, 0].max * 60).to_f
end

.restarts_onTime

Calculates the time when the gift will restart.

Examples:

Getting restart time

restart_time = Lich::Gemstone::Gift.restarts_on

Returns:

  • (Time)

    The time when the gift restarts.



54
55
56
# File 'documented/gemstone/gift.rb', line 54

def restarts_on
  @gift_start + 594000
end

.serializeArray

Serializes the current state of the gift.

Examples:

Serializing the gift state

serialized_data = Lich::Gemstone::Gift.serialize

Returns:

  • (Array)

    An array containing the gift start time and pulse count.



62
63
64
# File 'documented/gemstone/gift.rb', line 62

def serialize
  [@gift_start, @pulse_count]
end

.startedvoid

This method returns an undefined value.

Starts the gift tracking by resetting the start time and pulse count.

Examples:

Starting the gift tracking

Lich::Gemstone::Gift.started


29
30
31
32
# File 'documented/gemstone/gift.rb', line 29

def started
  @gift_start = Time.now
  @pulse_count = 0
end

.stopwatchnil

Placeholder method for stopwatch functionality.

Examples:

Using the stopwatch method

Lich::Gemstone::Gift.stopwatch

Returns:

  • (nil)

    This method currently does nothing.



88
89
90
# File 'documented/gemstone/gift.rb', line 88

def stopwatch
  nil
end