Class: Slurper
- Inherits:
-
Object
- Object
- Slurper
- Defined in:
- lib/slurper.rb
Instance Attribute Summary collapse
-
#note_file ⇒ Object
Returns the value of attribute note_file.
-
#notes ⇒ Object
Returns the value of attribute notes.
Class Method Summary collapse
Instance Method Summary collapse
- #create_notes(tag) ⇒ Object
-
#initialize(note_file) ⇒ Slurper
constructor
A new instance of Slurper.
- #load_notes ⇒ Object
- #prepare_notes ⇒ Object
Constructor Details
#initialize(note_file) ⇒ Slurper
Returns a new instance of Slurper.
16 17 18 |
# File 'lib/slurper.rb', line 16 def initialize(note_file) self.note_file = note_file end |
Instance Attribute Details
#note_file ⇒ Object
Returns the value of attribute note_file.
5 6 7 |
# File 'lib/slurper.rb', line 5 def note_file @note_file end |
#notes ⇒ Object
Returns the value of attribute notes.
5 6 7 |
# File 'lib/slurper.rb', line 5 def notes @notes end |
Class Method Details
Instance Method Details
#create_notes(tag) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/slurper.rb', line 28 def create_notes(tag) puts "Preparing to slurp #{notes.size} notes into ProjectNotifier..." notes.each_with_index do |note, index| begin unless tag.nil? = note.tag_list || "" = .split(",") tag.split(",").each do |tag_param| << tag_param end note.tag_list = .join(",") end if note.save puts "#{index+1}. #{note.subject}" else puts "Slurp failed. #{note.errors.}" end rescue ActiveResource::ConnectionError => e msg = "Slurp failed on note " if note.attributes["subject"] msg << note.attributes["subject"] else msg << "##{[:reverse] ? index + 1 : notes.size - index }" end puts msg + ". Error: #{e}" end end end |
#load_notes ⇒ Object
20 21 22 |
# File 'lib/slurper.rb', line 20 def load_notes self.notes = YAML.load(yamlize_note_file) end |
#prepare_notes ⇒ Object
24 25 26 |
# File 'lib/slurper.rb', line 24 def prepare_notes notes.each { |note| note.prepare } end |