Class: Zgomot::Midi::Time
Instance Attribute Summary collapse
-
#beat ⇒ Object
readonly
Returns the value of attribute beat.
-
#measure ⇒ Object
readonly
Returns the value of attribute measure.
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
-
#tick ⇒ Object
readonly
Returns the value of attribute tick.
Instance Method Summary collapse
- #+(add_time) ⇒ Object
-
#initialize(args = nil) ⇒ Time
constructor
A new instance of Time.
- #to_f ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(args = nil) ⇒ Time
Returns a new instance of Time.
7 8 9 10 11 12 13 |
# File 'lib/zgomot/midi/clock.rb', line 7 def initialize(args=nil) if args.kind_of?(Hash) [:measure, :beat, :tick].each{|a| raise(Zgomot::Error, "#{a} is a required argument") unless args.include?(a)} init_with_measure_beat_tick(args) elsif args.nil?; init_with_nil elsif args.kind_of?(Float); init_with_seconds(args); end end |
Instance Attribute Details
#beat ⇒ Object (readonly)
Returns the value of attribute beat.
5 6 7 |
# File 'lib/zgomot/midi/clock.rb', line 5 def beat @beat end |
#measure ⇒ Object (readonly)
Returns the value of attribute measure.
5 6 7 |
# File 'lib/zgomot/midi/clock.rb', line 5 def measure @measure end |
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds.
5 6 7 |
# File 'lib/zgomot/midi/clock.rb', line 5 def seconds @seconds end |
#tick ⇒ Object (readonly)
Returns the value of attribute tick.
5 6 7 |
# File 'lib/zgomot/midi/clock.rb', line 5 def tick @tick end |
Instance Method Details
#+(add_time) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zgomot/midi/clock.rb', line 20 def +(add_time) add_sec = if add_time.kind_of?(Float) add_time elsif add_time.kind_of?(Zgomot::Midi::Time) add_time.to_f else raise(Zgomot::Error, "#{add_time.class.name} is invalid. Must be Float or Zgomot::Midi::Time") end self.class.new(seconds+add_sec) end |
#to_f ⇒ Object
17 18 19 |
# File 'lib/zgomot/midi/clock.rb', line 17 def to_f seconds end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/zgomot/midi/clock.rb', line 14 def to_s "%d:%d:%d" % [measure, beat, tick] end |