Class: MidiLyrics::Parser
- Inherits:
-
Object
- Object
- MidiLyrics::Parser
- Defined in:
- lib/midi_lyrics.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#repeating ⇒ Object
readonly
Returns the value of attribute repeating.
Instance Method Summary collapse
- #extract ⇒ Object
-
#initialize(file, options = {}) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(file, options = {}) ⇒ Parser
Returns a new instance of Parser.
78 79 80 81 82 83 84 85 86 |
# File 'lib/midi_lyrics.rb', line 78 def initialize(file, = {}) = { repeating: false }.merge() @file = file @repeating = [:repeating] unless File.exists?(file) raise MidiLyrics::FileNotFound end end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
76 77 78 |
# File 'lib/midi_lyrics.rb', line 76 def file @file end |
#repeating ⇒ Object (readonly)
Returns the value of attribute repeating.
76 77 78 |
# File 'lib/midi_lyrics.rb', line 76 def repeating @repeating end |
Instance Method Details
#extract ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/midi_lyrics.rb', line 88 def extract read_sequence_from_file load_tempo_track load_tracks calculate_durations load_lyrics remove_heading_blank_lines consolidate_empty_syllables remove_lines_trailing_spaces fix_durations remove_repeating unless repeating calculate_seconds @lyrics.collect(&:as_json) end |