Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/core_ext/numeric.rb
Class Method Summary collapse
-
.tick_interval ⇒ Object
The game tick interval.
-
.tick_interval=(value) ⇒ Object
Set the tick interval which is used in conversion of seconds to ticks.
Instance Method Summary collapse
-
#second ⇒ Object
(also: #seconds, #secs, #sec)
Provides the suffix ‘second’ which will translate seconds to game ticks.
-
#tick ⇒ Object
(also: #ticks)
Provides the suffix ‘tick’ which will simply express the number with a vanity suffix.
Class Method Details
.tick_interval ⇒ Object
Returns the game tick interval. By default the tick interval is 16.66666.
14 15 16 |
# File 'lib/core_ext/numeric.rb', line 14 def self.tick_interval @tick_interval.to_f == 0 ? 16.666666 : @tick_interval.to_f end |
.tick_interval=(value) ⇒ Object
Set the tick interval which is used in conversion of seconds to ticks.
7 8 9 |
# File 'lib/core_ext/numeric.rb', line 7 def self.tick_interval=(value) @tick_interval = value.to_f end |
Instance Method Details
#second ⇒ Object Also known as: seconds, secs, sec
Provides the suffix ‘second’ which will translate seconds to game ticks. This is to allow for a number of seconds to be expressed in situations where game ticks are used (e.g. animations).
33 34 35 |
# File 'lib/core_ext/numeric.rb', line 33 def second (self * 1000 / Numeric.tick_interval).floor end |
#tick ⇒ Object Also known as: ticks
Provides the suffix ‘tick’ which will simply express the number with a vanity suffix.
53 54 55 |
# File 'lib/core_ext/numeric.rb', line 53 def tick self end |