Class: Todoly::Filter

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rest_if, obj) ⇒ Filter

Returns a new instance of Filter.



10
11
12
13
14
15
# File 'lib/todoly/filter.rb', line 10

def initialize(rest_if, obj)
  @rest_if = rest_if
  @raw = obj
  @id = obj["Id"]
  @name = obj["Content"]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



17
18
19
# File 'lib/todoly/filter.rb', line 17

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/todoly/filter.rb', line 17

def name
  @name
end

#rawObject (readonly)

Returns the value of attribute raw.



17
18
19
# File 'lib/todoly/filter.rb', line 17

def raw
  @raw
end

Class Method Details

.list(rest_if) ⇒ Object



4
5
6
7
8
# File 'lib/todoly/filter.rb', line 4

def self.list(rest_if)
  rest_if.filters.map do |f|
    self.new(rest_if, f)
  end
end

Instance Method Details

#[](key) ⇒ Object



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

def [](key)
  @raw[key]
end

#tasksObject



23
24
25
26
27
# File 'lib/todoly/filter.rb', line 23

def tasks
  @rest_if.items_of_filter(@id).map do |item|
    Task.new(@rest_if, item)
  end
end