Class: Insulin::OnTrackNote
- Inherits:
-
Object
- Object
- Insulin::OnTrackNote
- Defined in:
- lib/insulin/on_track_note.rb
Overview
Class representing a single OnTrack note
Constant Summary collapse
- @@keys =
Lookups. We will only deal with notes of these types
{ "F" => 'food', "B" => 'booze', "N" => 'note' }
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(n) ⇒ OnTrackNote
constructor
Parse the raw note ānā.
Constructor Details
#initialize(n) ⇒ OnTrackNote
Parse the raw note ānā
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 44 |
# File 'lib/insulin/on_track_note.rb', line 18 def initialize n # Key/value splits on ':' bits = n.split ":" # Remove leading/trailing cruft from key part t = bits[0].strip # We only deal with the keys we know about if @@keys.keys.include? t # Remove cruft from content, downcase @content = bits[1].strip.downcase # These keys mean we turn the content into a list if ["F", "B"].include? t a = [] @content.split(",").each do |v| a << v.strip end @content = a end # Set key from lookup list @type = @@keys[t] end end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
15 16 17 |
# File 'lib/insulin/on_track_note.rb', line 15 def content @content end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/insulin/on_track_note.rb', line 15 def type @type end |