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.
- #make_url(path = '/', params = {}) ⇒ Object
- #pages ⇒ Object
- #password ⇒ 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
#make_url(path = '/', params = {}) ⇒ Object
32 33 34 35 |
# File 'lib/springnote_client.rb', line 32 def make_url(path = '/', params = {}) query = params.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&') "http://api.springnote.com#{path}?domain=#{@name}&#{query}" end |
#pages ⇒ Object
19 20 21 22 |
# File 'lib/springnote_client.rb', line 19 def pages raise ConfigurationMissing unless @config[:app_key] CallProxy.new(Page, self) end |
#password ⇒ Object
28 29 30 |
# File 'lib/springnote_client.rb', line 28 def password @config[:user_key] ? "#{@config[:user_key]}.#{@config[:app_key]}" : @config[:app_key] end |
#username ⇒ Object
24 25 26 |
# File 'lib/springnote_client.rb', line 24 def username CGI.escape(@config[:user_openid] || 'anonymous') end |