Class: Gotasku::Query
- Inherits:
-
Object
- Object
- Gotasku::Query
- Defined in:
- lib/gotasku/query.rb
Constant Summary collapse
- @@problems =
Mongo::MongoClient.new.db('sgf').collection('problems')
Instance Attribute Summary collapse
-
#found ⇒ Object
readonly
Returns the value of attribute found.
Class Method Summary collapse
-
.create ⇒ Object
returns a Mongo::Cursor object.
Instance Method Summary collapse
-
#initialize(query) ⇒ Query
constructor
gets a Mongo::Cursor object.
-
#to_a ⇒ Object
returns an array of items in @found.
Constructor Details
#initialize(query) ⇒ Query
gets a Mongo::Cursor object
7 8 9 |
# File 'lib/gotasku/query.rb', line 7 def initialize(query) @found = @@problems.find(query) end |
Instance Attribute Details
#found ⇒ Object (readonly)
Returns the value of attribute found.
4 5 6 |
# File 'lib/gotasku/query.rb', line 4 def found @found end |
Class Method Details
.create ⇒ Object
returns a Mongo::Cursor object
18 19 20 |
# File 'lib/gotasku/query.rb', line 18 def self.create self.new(self.build_query) end |
Instance Method Details
#to_a ⇒ Object
returns an array of items in @found
12 13 14 15 |
# File 'lib/gotasku/query.rb', line 12 def to_a @found.rewind! @found.to_a end |