Class: Wreckster::Traversal
- Inherits:
-
Object
- Object
- Wreckster::Traversal
- Defined in:
- lib/wreckster/traversal.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #find(options = {}) ⇒ Object
- #info ⇒ Object
-
#initialize(base, name) ⇒ Traversal
constructor
A new instance of Traversal.
- #url ⇒ Object
Constructor Details
#initialize(base, name) ⇒ Traversal
Returns a new instance of Traversal.
7 8 9 10 |
# File 'lib/wreckster/traversal.rb', line 7 def initialize base, name @base = base @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/wreckster/traversal.rb', line 5 def name @name end |
Instance Method Details
#find(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/wreckster/traversal.rb', line 12 def find = {} params = .map { |k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&") map = JSON.parse( Wreckster.connection.request(URI.parse(url + "?#{params}")).body ) return map['score'] if map.key?('score') map['ranks'].map { |thing| Wreckster::Object.new(name, thing) } end |
#info ⇒ Object
22 23 24 |
# File 'lib/wreckster/traversal.rb', line 22 def info JSON.parse Net::HTTP.get(URI.parse(url)) end |
#url ⇒ Object
26 27 28 |
# File 'lib/wreckster/traversal.rb', line 26 def url @base + @name end |