Class: Springnote::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/springnote_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject

Returns the value of attribute config.



12
13
14
# File 'lib/springnote_client.rb', line 12

def config
  @config
end

#nameObject

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

#pagesObject



19
20
21
22
# File 'lib/springnote_client.rb', line 19

def pages
  raise ConfigurationMissing unless @config[:app_key]
  CallProxy.new(Page, self)
end

#passwordObject



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

#usernameObject



24
25
26
# File 'lib/springnote_client.rb', line 24

def username
  CGI.escape(@config[:user_openid] || 'anonymous')
end