Sha256: 0999c41ef2fb5211c0a1245d69a2c4d75f65fc762957d351501307031ba82650
Contents?: true
Size: 1.05 KB
Versions: 17
Compression:
Stored size: 1.05 KB
Contents
module Insulin # Author:: Sam (mailto:sam@cruft.co) # License:: MIT module OnTrack # Class representing a single OnTrack note class Note # Lookups. We will only deal with notes of these types @@keys = { "F" => 'food', "B" => 'booze', "N" => 'note' } attr_reader :type, :content # Parse the raw note 'n' 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 end end end
Version data entries
17 entries across 17 versions & 1 rubygems