Class: Rflak::Traker

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/traker.rb

Overview

Utility class to fetch entries from flaker.pl traker service

Example:

Traker.fetch do |traker|
  traker.url 'http://blog.sebastiannowak.net'
  traker.limit 20
end

Constant Summary collapse

FLAK_API_URL =
'http://api.flaker.pl/api/type:traker'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTraker

Returns a new instance of Traker.



20
21
22
# File 'lib/traker.rb', line 20

def initialize
  @perform_url = FLAK_API_URL
end

Instance Attribute Details

#perform_urlObject (readonly)

Returns the value of attribute perform_url.



18
19
20
# File 'lib/traker.rb', line 18

def perform_url
  @perform_url
end

Class Method Details

.fetch {|traker| ... } ⇒ Object

Yields:

  • (traker)


25
26
27
28
29
# File 'lib/traker.rb', line 25

def self.fetch
  traker = Traker.new
  yield(traker) if block_given?
  parse_response get(traker.perform_url)
end

Instance Method Details

#avatars(size) ⇒ Object



42
43
44
# File 'lib/traker.rb', line 42

def avatars(size)
  @perform_url += "/avatars:#{ size }"
end

#format(format) ⇒ Object



37
38
39
# File 'lib/traker.rb', line 37

def format(format)
  @perform_url += "/format:#{ format }"
end

#limit(value) ⇒ Object



47
48
49
# File 'lib/traker.rb', line 47

def limit(value)
  @perform_url += "/limit:#{ value }"
end

#url(url) ⇒ Object



32
33
34
# File 'lib/traker.rb', line 32

def url(url)
  @perform_url += "/url:#{ url }"
end