Class: Delicious::Bookmarks::Methods::All::Criteria

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/delicious/bookmarks/methods/all.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Criteria

Returns a new instance of Criteria.



40
41
42
# File 'lib/delicious/bookmarks/methods/all.rb', line 40

def initialize(&block)
  @fetch = block
end

Class Method Details

.param(param) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/delicious/bookmarks/methods/all.rb', line 13

def self.param(param)
  method, query_param = param.is_a?(Hash) ? param.first : [param, param]
  define_method method do |value|
    params[query_param] = value
    self
  end
end

Instance Method Details

#each(&block) ⇒ Object

Fetches bookmarks from server filtering by current criteria



63
64
65
# File 'lib/delicious/bookmarks/methods/all.rb', line 63

def each(&block)
  @fetch.call(self).each(&block)
end

#from(date) ⇒ Criteria

Sets starting date and time for which you want to get bookmarks

Parameters:

  • date (String, Time, DateTime)

    ‘String` time represenation or any object which responds to `strftime`

Returns:



49
50
51
52
# File 'lib/delicious/bookmarks/methods/all.rb', line 49

def from(date)
  params[:fromdt] = format_time(date)
  self
end

#limit(count) ⇒ Criteria

Sets the limit

Parameters:

  • count (Integer)

    How many bookmarks server should return at most

Returns:



26
# File 'lib/delicious/bookmarks/methods/all.rb', line 26

param limit: :results

#offset(count) ⇒ Criteria

Sets the offset

Parameters:

  • count (Integer)

    How many bookmarks server should skip

Returns:



32
# File 'lib/delicious/bookmarks/methods/all.rb', line 32

param offset: :start

#paramsObject



67
68
69
# File 'lib/delicious/bookmarks/methods/all.rb', line 67

def params
  @params ||= {}
end

#tag(name) ⇒ Criteria

Sets tag-based filtering

Parameters:

  • name (String)

    Name of the tag

Returns:



38
# File 'lib/delicious/bookmarks/methods/all.rb', line 38

param :tag

#to(date) ⇒ Criteria

Sets ending date and time for which you want to get bookmarks

Parameters:

  • date (String, Time, DateTime)

    ‘String` time represenation or any object which responds to `strftime`

Returns:



57
58
59
60
# File 'lib/delicious/bookmarks/methods/all.rb', line 57

def to(date)
  params[:todt] = format_time(date)
  self
end