Class: Insulin::OnTrackNoteSet
- Inherits:
-
Hash
- Object
- Hash
- Insulin::OnTrackNoteSet
- Defined in:
- lib/insulin/on_track_note_set.rb
Overview
This class represents a set of notes
Instance Method Summary collapse
-
#initialize(s) ⇒ OnTrackNoteSet
constructor
Parse the string āsā.
Constructor Details
#initialize(s) ⇒ OnTrackNoteSet
Parse the string āsā
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/insulin/on_track_note_set.rb', line 9 def initialize s # Notes separated by newlines l = s.split"\n" # For each line l.each do |n| # Make a note x = OnTrackNote.new n # This field will only exists for notes of a valid type if x.type # If we don't yet have this key if not self[x.type] # If the content is a list if x.content.class.name == "Array" # This becomes our value self[x.type] = x.content else # Otherwise make it onto a list self[x.type] = [x.content] end else # This key exists, so we append this value self[x.type] << x.content end end end end |