Class: Dobedobedo::Note

Inherits:
Object
  • Object
show all
Includes:
ObjToJson
Defined in:
lib/dobedobedo/note.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ObjToJson

#objToJson, #obj_to_json, #obj_to_json2

Constructor Details

#initialize(token, workspace_id, h = {}) ⇒ Note

Returns a new instance of Note.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dobedobedo/note.rb', line 7

def initialize(token, workspace_id, h={})
  @token = token
  @workspace_id = workspace_id
  if h.empty?
    h = token.post("/workspaces/#{workspace_id}/notes").parsed
  end
  h.each do |k,v|
    Note.send(:attr_accessor, k.to_sym)
    self.send("#{k}=".to_sym, v)
  end
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



5
6
7
# File 'lib/dobedobedo/note.rb', line 5

def token
  @token
end

Class Method Details

.create(token, workspace_id) ⇒ Object



23
24
25
# File 'lib/dobedobedo/note.rb', line 23

def self.create(token, workspace_id)
  Note.new(token, workspace_id, token.post("/workspaces/#{workspace_id}/notes").parsed)
end

.get(token, workspace_id, note_id) ⇒ Object



19
20
21
# File 'lib/dobedobedo/note.rb', line 19

def self.get(token, workspace_id, note_id)
  Note.new(token, workspace_id, token.get("/workspaces/#{workspace_id}/notes/#{note_id}").parsed)
end

Instance Method Details

#deleteObject

alias :update :save



32
33
34
# File 'lib/dobedobedo/note.rb', line 32

def delete()
  @token.delete("/workspaces/#{@workspace_id}/notes/#{@id}")
end

#updateObject



27
28
29
# File 'lib/dobedobedo/note.rb', line 27

def update()
  @token.put("/workspaces/#{@workspace_id}/notes/#{@id}", :body => self.objToJson)
end