Class: RTM::List
- Inherits:
-
Object
- Object
- RTM::List
- Defined in:
- lib/rtmilk/api/lists.rb
Overview
more friendly class.
Class Method Summary collapse
-
.alive_all ⇒ Object
find all alive Lists.
-
.find(name, alive_only = true) ⇒ Object
find a List by name.
-
.find_all(name, alive_only = true) ⇒ Object
find all Lists.
- .get ⇒ Object
- .inbox ⇒ Object
Instance Method Summary collapse
-
#archive ⇒ Object
archive this list.
- #archived? ⇒ Boolean
-
#delete ⇒ Object
delete this list.
- #deleted? ⇒ Boolean
- #id ⇒ Object
-
#initialize(arg) ⇒ List
constructor
attr_reader :name, :smart, :id, :archived, :deleted, :position, :locked.
- #locked? ⇒ Boolean
- #name ⇒ Object
- #name=(new_name) ⇒ Object
- #position ⇒ Object
-
#set_default ⇒ Object
set this list as default.
- #smart? ⇒ Boolean
-
#unarchive ⇒ Object
unarchive this list.
Constructor Details
#initialize(arg) ⇒ List
attr_reader :name, :smart, :id, :archived, :deleted, :position, :locked
85 86 87 88 89 90 91 92 93 |
# File 'lib/rtmilk/api/lists.rb', line 85 def initialize(arg) if arg.class == String # name @hash = RTM::Lists::Add.new(RTM::API.token, arg).invoke elsif arg.class == Hash # already constructed @hash = arg else raise RTM::Error, "invalid argument" end end |
Class Method Details
.alive_all ⇒ Object
find all alive Lists.
158 159 160 161 162 163 164 165 |
# File 'lib/rtmilk/api/lists.rb', line 158 def List.alive_all lists = RTM::Lists::GetList.new(RTM::API.token).invoke lists.find_all do |list| list['archived'] == '0' && list['deleted'] == '0' end.collect do |x| List.new(x) end end |
.find(name, alive_only = true) ⇒ Object
find a List by name.
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/rtmilk/api/lists.rb', line 132 def List.find(name, alive_only=true) # by name lists = RTM::Lists::GetList.new(RTM::API.token).invoke lists.find do |list| if alive_only list['name'] == name && list['archived'] == '0' && list['deleted'] == '0' else list['name'] == name end end end |
.find_all(name, alive_only = true) ⇒ Object
find all Lists.
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/rtmilk/api/lists.rb', line 144 def List.find_all(name, alive_only=true) # by name lists = RTM::Lists::GetList.new(RTM::API.token).invoke lists.find_all do |list| if alive_only list['name'] == name && list['archived'] == '0' && list['deleted'] == '0' else list['name'] == name end end.collect do |x| List.new(x) end end |
.get ⇒ Object
168 169 |
# File 'lib/rtmilk/api/lists.rb', line 168 def List.get end |
Instance Method Details
#archive ⇒ Object
archive this list. www.rememberthemilk.com/services/api/methods/rtm.lists.archive.rtm
109 110 |
# File 'lib/rtmilk/api/lists.rb', line 109 def archive end |
#archived? ⇒ Boolean
99 |
# File 'lib/rtmilk/api/lists.rb', line 99 def archived?; @hash['archived'] == '1'; end |
#delete ⇒ Object
delete this list. www.rememberthemilk.com/services/api/methods/rtm.lists.delete.rtm
118 119 120 |
# File 'lib/rtmilk/api/lists.rb', line 118 def delete deleted = RTM::Lists::Delete.new(RTM::API.token, @hash['id']).invoke end |
#deleted? ⇒ Boolean
101 |
# File 'lib/rtmilk/api/lists.rb', line 101 def deleted?; @hash['deleted'] == '1'; end |
#id ⇒ Object
96 |
# File 'lib/rtmilk/api/lists.rb', line 96 def id; @hash['id']; end |
#locked? ⇒ Boolean
100 |
# File 'lib/rtmilk/api/lists.rb', line 100 def locked?; @hash['locked'] == '1'; end |
#name ⇒ Object
95 |
# File 'lib/rtmilk/api/lists.rb', line 95 def name; @hash['name']; end |
#name=(new_name) ⇒ Object
103 104 105 |
# File 'lib/rtmilk/api/lists.rb', line 103 def name=(new_name) RTM::API::SetName(RTM::API.token, @id, new_name) end |
#position ⇒ Object
97 |
# File 'lib/rtmilk/api/lists.rb', line 97 def position; @hash['position']; end |
#set_default ⇒ Object
set this list as default. www.rememberthemilk.com/services/api/methods/rtm.lists.setDefaultList.rtm
124 125 |
# File 'lib/rtmilk/api/lists.rb', line 124 def set_default end |
#smart? ⇒ Boolean
98 |
# File 'lib/rtmilk/api/lists.rb', line 98 def smart?; @hash['smart'] == '1'; end |
#unarchive ⇒ Object
unarchive this list.
113 114 |
# File 'lib/rtmilk/api/lists.rb', line 113 def unarchive end |