Class: Springnote::Note
- Inherits:
-
Object
- Object
- Springnote::Note
- Defined in:
- lib/springnote_client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, config) ⇒ Note
constructor
config should have app_key, user_openid, user_key.
- #pages ⇒ Object
- #password ⇒ Object
- #url(path = '/', params = {}) ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(name, config) ⇒ Note
config should have app_key, user_openid, user_key
15 16 17 |
# File 'lib/springnote_client.rb', line 15 def initialize(name, config) @name, @config = name, config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12 13 14 |
# File 'lib/springnote_client.rb', line 12 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/springnote_client.rb', line 12 def name @name end |
Instance Method Details
#pages ⇒ Object
19 20 21 |
# File 'lib/springnote_client.rb', line 19 def pages CallProxy.new(Page, self) end |
#password ⇒ Object
27 28 29 |
# File 'lib/springnote_client.rb', line 27 def password @config[:user_key] ? "#{@config[:user_key]}.#{@config[:app_key]}" : @config[:app_key] end |
#url(path = '/', params = {}) ⇒ Object
31 32 33 34 |
# File 'lib/springnote_client.rb', line 31 def url(path = '/', params = {}) query = params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') "http://api.springnote.com#{path}?domain=#{@name}&#{query}" end |
#username ⇒ Object
23 24 25 |
# File 'lib/springnote_client.rb', line 23 def username CGI.escape(@config[:user_openid] || 'anonymous') end |