Class: Insulin::OnTrack::Note
- Inherits:
-
Object
- Object
- Insulin::OnTrack::Note
- 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) ⇒ Note
constructor
Parse the raw note ‘n’.
Constructor Details
#initialize(n) ⇒ Note
Parse the raw note ‘n’
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 45 46 |
# File 'lib/insulin/on_track/note.rb', line 20 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.
17 18 19 |
# File 'lib/insulin/on_track/note.rb', line 17 def content @content end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/insulin/on_track/note.rb', line 17 def type @type end |