Class: RubyCue::Index
- Inherits:
-
Object
- Object
- RubyCue::Index
- Defined in:
- lib/rubycue/index.rb
Constant Summary collapse
- SECONDS_PER_MINUTE =
60
- FRAMES_PER_SECOND =
75
- FRAMES_PER_MINUTE =
FRAMES_PER_SECOND * 60
Instance Attribute Summary collapse
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #each ⇒ Object
-
#initialize(value = nil) ⇒ Index
constructor
A new instance of Index.
- #to_a ⇒ Object
- #to_f ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value = nil) ⇒ Index
Returns a new instance of Index.
9 10 11 12 13 14 15 16 |
# File 'lib/rubycue/index.rb', line 9 def initialize(value=nil) case value when Array set_from_array!(value) when Integer set_from_integer!(value) end end |
Instance Attribute Details
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
7 8 9 |
# File 'lib/rubycue/index.rb', line 7 def frames @frames end |
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
7 8 9 |
# File 'lib/rubycue/index.rb', line 7 def minutes @minutes end |
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds.
7 8 9 |
# File 'lib/rubycue/index.rb', line 7 def seconds @seconds end |
Instance Method Details
#+(other) ⇒ Object
34 35 36 |
# File 'lib/rubycue/index.rb', line 34 def +(other) self.class.new((other)) end |
#-(other) ⇒ Object
38 39 40 |
# File 'lib/rubycue/index.rb', line 38 def -(other) self.class.new((other)) end |
#<(other) ⇒ Object
46 47 48 |
# File 'lib/rubycue/index.rb', line 46 def <(other) self.to_f < other.to_f end |
#==(other) ⇒ Object
50 51 52 |
# File 'lib/rubycue/index.rb', line 50 def ==(other) self.to_a == other.to_a end |
#>(other) ⇒ Object
42 43 44 |
# File 'lib/rubycue/index.rb', line 42 def >(other) self.to_f > other.to_f end |
#each ⇒ Object
54 55 56 |
# File 'lib/rubycue/index.rb', line 54 def each to_a.each {|value| yield value } end |
#to_a ⇒ Object
26 27 28 |
# File 'lib/rubycue/index.rb', line 26 def to_a [@minutes, @seconds, @frames] end |
#to_f ⇒ Object
18 19 20 |
# File 'lib/rubycue/index.rb', line 18 def to_f ((@minutes * SECONDS_PER_MINUTE) + (@seconds) + (@frames.to_f / FRAMES_PER_SECOND)).to_f end |
#to_i ⇒ Object
22 23 24 |
# File 'lib/rubycue/index.rb', line 22 def to_i to_f.floor end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/rubycue/index.rb', line 30 def to_s "#{'%02d' % @minutes}:#{'%02d' % @seconds}:#{'%02d' % @frames}" end |