Class: MongoDbUtils::Tools::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo-db-utils/tools/commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value = nil) ⇒ Option

Returns a new instance of Option.



114
115
116
117
# File 'lib/mongo-db-utils/tools/commands.rb', line 114

def initialize(key,value = nil)
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



112
113
114
# File 'lib/mongo-db-utils/tools/commands.rb', line 112

def key
  @key
end

#valueObject

Returns the value of attribute value.



112
113
114
# File 'lib/mongo-db-utils/tools/commands.rb', line 112

def value
  @value
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/mongo-db-utils/tools/commands.rb', line 119

def empty?
  (@value.nil? || @value.empty?)
end

#to_sObject



123
124
125
126
127
128
129
# File 'lib/mongo-db-utils/tools/commands.rb', line 123

def to_s
  if empty?
    nil
  else
    "#{@key} #{@value}"
  end
end