Class: Wunderlist::List
- Inherits:
-
Object
- Object
- Wunderlist::List
- Defined in:
- lib/wunderlist/list.rb
Constant Summary collapse
- ATTRIBUTES =
[ :deleted, :inbox, :name, :online_id, :position, :shared, :user_id, :version, ]
Class Method Summary collapse
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(data = {}) ⇒ List
constructor
A new instance of List.
- #online_id? ⇒ Boolean
- #sync_data ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ List
Returns a new instance of List.
21 22 23 24 25 26 |
# File 'lib/wunderlist/list.rb', line 21 def initialize data = {} data.each do |k,v| self.send("%s=" % k, v) if ATTRIBUTES.include? k end self.version ||= 0 end |
Class Method Details
.from_sync_data(web_data) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/wunderlist/list.rb', line 50 def self.from_sync_data web_data data = Hash.new web_data.each do |k,v| case k.to_s when 'deleted', 'inbox', 'shared' data[k.to_sym] = v != '0' when 'name' data[:name] = v.to_s else data[k.to_sym] = v.to_i end end Wunderlist::List.new(data) end |
Instance Method Details
#hash ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/wunderlist/list.rb', line 28 def hash data = Hash.new ATTRIBUTES.each do |key| data[key] = self.send(key) end data end |
#online_id? ⇒ Boolean
17 18 19 |
# File 'lib/wunderlist/list.rb', line 17 def online_id? online_id && online_id != 0 end |
#sync_data ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/wunderlist/list.rb', line 36 def sync_data data = self.hash web_data = Hash.new data.each do |k,v| case k when :deleted, :inbox, :shared web_data[k] = v ? 1 : 0 else web_data[k] = v end end web_data end |