class Delicious::Bookmarks::Methods::All::Criteria

Public Class Methods

new(&block) click to toggle source
# File lib/delicious/bookmarks/methods/all.rb, line 40
def initialize(&block)
  @fetch = block
end
param(param) click to toggle source
# 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

Public Instance Methods

each(&block) click to toggle source

Fetches bookmarks from server filtering by current criteria

# File lib/delicious/bookmarks/methods/all.rb, line 63
def each(&block)
  @fetch.call(self).each(&block)
end
from(date) click to toggle source

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

@!macro [new] time_criteria

@param date [String,Time,DateTime] `String` time represenation or any object which responds to `strftime`
@return [Criteria]
# File lib/delicious/bookmarks/methods/all.rb, line 49
def from(date)
  params[:fromdt] = format_time(date)
  self
end
params() click to toggle source
# File lib/delicious/bookmarks/methods/all.rb, line 67
def params
  @params ||= {}
end
to(date) click to toggle source

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

@!macro time_criteria

# File lib/delicious/bookmarks/methods/all.rb, line 57
def to(date)
  params[:todt] = format_time(date)
  self
end

Private Instance Methods

format_time(time) click to toggle source
# File lib/delicious/bookmarks/methods/all.rb, line 73
def format_time(time)
  time = Time.parse(time) if time.respond_to?(:to_str)
  time.strftime "%FT%TZ"
end