Class: RememberTheRuby::API

Inherits:
Object
  • Object
show all
Defined in:
lib/remember-the-ruby/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ API

Returns a new instance of API.



4
5
6
7
8
9
10
11
# File 'lib/remember-the-ruby/api.rb', line 4

def initialize(options={})
  @transport = RPC::Transport.new(
    :key    => 'cb877b5c450d216ce9e563394dff6c07', 
    :secret => '97cbbc48a9b1b54c', 
    :frob   => options[:frob], 
    :token  => options[:token]    
  )
end

Instance Method Details

#authenticateObject



18
19
20
# File 'lib/remember-the-ruby/api.rb', line 18

def authenticate
  self.token = @transport.auth.get_token
end

#authorization_urlObject



13
14
15
16
# File 'lib/remember-the-ruby/api.rb', line 13

def authorization_url
  self.frob = @transport.auth.get_frob
  @transport.auth.get_authorization_url
end

#default_listObject

derivative objects ######################################################



38
39
40
# File 'lib/remember-the-ruby/api.rb', line 38

def default_list
  lists.find(settings["defaultlist"])
end

#frobObject

accessors ##############################################################



61
62
63
# File 'lib/remember-the-ruby/api.rb', line 61

def frob
  @transport.frob
end

#frob=(frob) ⇒ Object



65
66
67
# File 'lib/remember-the-ruby/api.rb', line 65

def frob=(frob)
  @transport.frob = frob
end

#listsObject

first-order objects #####################################################



24
25
26
# File 'lib/remember-the-ruby/api.rb', line 24

def lists
  @transport.lists.get_list
end

#settingsObject



28
29
30
# File 'lib/remember-the-ruby/api.rb', line 28

def settings
  @transport.settings.get_list
end

#tagsObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/remember-the-ruby/api.rb', line 42

def tags
  found_tags = EntityList.new(@transport, Tag)
  tasks.each do |task|
    task.tags.each do |tag|
      found = false
      found_tags.each do |found_tag|
        if tag.to_s == found_tag.to_s
          found = true
          break
        end
      end
      found_tags << tag unless found
    end
  end
  found_tags
end

#tasksObject



32
33
34
# File 'lib/remember-the-ruby/api.rb', line 32

def tasks
  @transport.tasks.get_list
end

#token=(token) ⇒ Object



69
70
71
# File 'lib/remember-the-ruby/api.rb', line 69

def token=(token)
  @transport.token = token
end