Class: Currently::Catchstore

Inherits:
Backingstore show all
Defined in:
lib/currently/catchstore.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, pass) ⇒ Catchstore

Returns a new instance of Catchstore.



7
8
9
10
# File 'lib/currently/catchstore.rb', line 7

def initialize(user,pass)
  @catch = Catch::Client.new(:username => user, :password => pass)
  @context = "#iac"
end

Instance Method Details

#allObject

retrieves all entries (or as many as can be found)



26
27
28
# File 'lib/currently/catchstore.rb', line 26

def all
  super
end

#last(n = 1, context = nil) ⇒ Object

retrieves last n entries



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/currently/catchstore.rb', line 13

def last(n = 1,context = nil)
  context ||= @context
  note_ids = @catch.search(context,:limit => n).map{|x| x["id"].to_i}
  ents = note_ids.map{|x|
    e = @catch.note(x)
    # Entry.new(e["text"],e["tags"],e["created_at"])
    # tags are already in the text, we don't want dupes
    Entry.new(e["text"],[],e["created_at"])
  }
  ents
end

#save(entry) ⇒ Object

saves the provided entry



31
32
33
# File 'lib/currently/catchstore.rb', line 31

def save(entry)
  @catch.add_note(:text => entry.to_s + " #{@context}")
end