Class: Rmr::Options

Inherits:
Object
  • Object
show all
Includes:
Mongo
Defined in:
lib/rmr.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Options

Returns a new instance of Options.



14
15
16
17
18
19
# File 'lib/rmr.rb', line 14

def initialize(args)
@server = args[:server] || 'localhost'
@port = args[:port] || '27017'
@db = args[:db] || 'test'
@collection = args[:collection] || 'test'
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



12
13
14
# File 'lib/rmr.rb', line 12

def collection
  @collection
end

#dbObject (readonly)

Returns the value of attribute db.



12
13
14
# File 'lib/rmr.rb', line 12

def db
  @db
end

#portObject (readonly)

Returns the value of attribute port.



12
13
14
# File 'lib/rmr.rb', line 12

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



12
13
14
# File 'lib/rmr.rb', line 12

def server
  @server
end

Instance Method Details

#account(identify) ⇒ Object



27
28
29
# File 'lib/rmr.rb', line 27

def (identify)
    @identify = identify
end

#find_accountObject



31
32
33
34
35
36
37
# File 'lib/rmr.rb', line 31

def 
    hashdata = Hash.new
    read_collection.find("account" => @identify).each do
        |value| hashdata.merge! value
    end
    return hashdata
end

#nameObject



39
40
41
# File 'lib/rmr.rb', line 39

def name
    ['name']
end

#passwordObject



43
44
45
# File 'lib/rmr.rb', line 43

def password
    ['password']
end

#read_collectionObject



21
22
23
24
25
# File 'lib/rmr.rb', line 21

def read_collection
    database = Connection.new(@server, @port).db(@db)
    collection = database[@collection]
    return collection
end