Class: Musikov::MidiElement
- Inherits:
-
Object
- Object
- Musikov::MidiElement
- Defined in:
- lib/musikov/markov_builder.rb
Overview
This class represents a state on the markov chain. This state is built from a note and a duration string representation.
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#note ⇒ Object
Returns the value of attribute note.
Instance Method Summary collapse
-
#==(comparison_object) ⇒ Object
Overriding comparison to be used on “==”.
-
#eql?(comparison_object) ⇒ Boolean
Overriding comparison to be used on hashing.
- #hash ⇒ Object
-
#initialize(note, duration) ⇒ MidiElement
constructor
Initializes the midi element by a note string and a string representation of the duration.
- #to_s ⇒ Object
Constructor Details
#initialize(note, duration) ⇒ MidiElement
Initializes the midi element by a note string and a string representation of the duration.
202 203 204 205 |
# File 'lib/musikov/markov_builder.rb', line 202 def initialize(note, duration) @note = note @duration = duration end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
199 200 201 |
# File 'lib/musikov/markov_builder.rb', line 199 def duration @duration end |
#note ⇒ Object
Returns the value of attribute note.
199 200 201 |
# File 'lib/musikov/markov_builder.rb', line 199 def note @note end |
Instance Method Details
#==(comparison_object) ⇒ Object
Overriding comparison to be used on “==”
208 209 210 211 212 213 |
# File 'lib/musikov/markov_builder.rb', line 208 def ==(comparison_object) comparison_object.equal?(self) || (comparison_object.instance_of?(self.class) && @note == comparison_object.note && @duration == comparison_object.duration) end |
#eql?(comparison_object) ⇒ Boolean
Overriding comparison to be used on hashing
216 217 218 219 220 |
# File 'lib/musikov/markov_builder.rb', line 216 def eql?(comparison_object) self.class.equal?(comparison_object.class) && @note == comparison_object.note && @duration == comparison_object.duration end |
#hash ⇒ Object
222 223 224 |
# File 'lib/musikov/markov_builder.rb', line 222 def hash @note.hash ^ @duration.hash end |
#to_s ⇒ Object
226 227 228 |
# File 'lib/musikov/markov_builder.rb', line 226 def to_s "[Note: #{@note} Duration: #{@duration}]" end |