Class: AudioPlayback::Position
- Inherits:
-
Object
- Object
- AudioPlayback::Position
- Extended by:
- Forwardable
- Defined in:
- lib/audio-playback/position.rb
Overview
A time position in a sound
Defined Under Namespace
Classes: InvalidTime
Constant Summary collapse
- UNITS =
[ 1, # second 60, # minute 3600 # hour ].freeze
- FORMAT =
Time format like (hh:)(mm:)ss(.ss)
/((\d+\:)(\d{2}\:)|(\d{2}\:))?\d{1,2}(\.\d+)?/.freeze
Instance Attribute Summary collapse
-
#seconds ⇒ Object
(also: #to_seconds)
readonly
Returns the value of attribute seconds.
Instance Method Summary collapse
-
#*(another) ⇒ Float
Multiply the seconds value of this Position by the given value.
-
#+(another) ⇒ Float
Add the seconds value of this Position to the given value.
-
#initialize(seconds_or_time) ⇒ Position
constructor
A new instance of Position.
Constructor Details
#initialize(seconds_or_time) ⇒ Position
Returns a new instance of Position.
25 26 27 28 29 |
# File 'lib/audio-playback/position.rb', line 25 def initialize(seconds_or_time) seconds_or_time = seconds_or_time.to_s validate_time(seconds_or_time) populate(seconds_or_time) end |
Instance Attribute Details
#seconds ⇒ Object (readonly) Also known as: to_seconds
Returns the value of attribute seconds.
20 21 22 |
# File 'lib/audio-playback/position.rb', line 20 def seconds @seconds end |
Instance Method Details
#*(another) ⇒ Float
Multiply the seconds value of this Position by the given value
34 35 36 |
# File 'lib/audio-playback/position.rb', line 34 def *(another) @seconds * another.to_f end |
#+(another) ⇒ Float
Add the seconds value of this Position to the given value
41 42 43 |
# File 'lib/audio-playback/position.rb', line 41 def +(another) @seconds + another.to_f end |