Class: SimpleNote
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #create_note(content) ⇒ Object
- #delete_note(key) ⇒ Object
- #get_index ⇒ Object
- #get_note(key) ⇒ Object
- #login(email, password) ⇒ Object
- #search(search_string, max_results = 10) ⇒ Object
- #update_note(key, content) ⇒ Object
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'lib/simplenote.rb', line 7 def email @email end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/simplenote.rb', line 7 def token @token end |
Instance Method Details
#create_note(content) ⇒ Object
37 38 39 |
# File 'lib/simplenote.rb', line 37 def create_note(content) self.class.post "/note", :query => request_hash, :body => Base64.encode64(content) end |
#delete_note(key) ⇒ Object
27 28 29 30 31 |
# File 'lib/simplenote.rb', line 27 def delete_note(key) out = self.class.get "/delete", :query => request_hash.merge(:key => key) raise "Couldn't delete note" unless out.response.is_a?(Net::HTTPOK) out end |
#get_index ⇒ Object
18 19 20 |
# File 'lib/simplenote.rb', line 18 def get_index self.class.get "/index", :query => request_hash, :format => :json end |
#get_note(key) ⇒ Object
22 23 24 25 |
# File 'lib/simplenote.rb', line 22 def get_note(key) out = self.class.get "/note", :query => request_hash.merge(:key => key), :format => :plain out.response.is_a?(Net::HTTPNotFound) ? nil : out end |
#login(email, password) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/simplenote.rb', line 11 def login(email, password) encoded_body = Base64.encode64({:email => email, :password => password}.to_params) @email = email @token = self.class.post "/login", :body => encoded_body raise "Login failed" unless @token.response.is_a?(Net::HTTPOK) end |
#search(search_string, max_results = 10) ⇒ Object
41 42 43 |
# File 'lib/simplenote.rb', line 41 def search(search_string, max_results=10) self.class.get "/search", :query => request_hash.merge(:query => search_string, :results => max_results) end |
#update_note(key, content) ⇒ Object
33 34 35 |
# File 'lib/simplenote.rb', line 33 def update_note(key, content) self.class.post "/note", :query => request_hash.merge(:key => key), :body => Base64.encode64(content) end |