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

#pagesObject



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

def pages
  CallProxy.new(Page, self)
end

#passwordObject



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

#usernameObject



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

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