class PerconaMigrator::Option

Attributes

name[R]
value[R]

Public Class Methods

from_string(string) click to toggle source

Builds an instance by parsing its name and value out of the given string. Note the string must conform to “–<arg>=<value>” format.

@param string [String] @return [Option]

# File lib/percona_migrator/option.rb, line 10
def self.from_string(string)
  pair = string.split('=')
  name = pair[0][2..-1]
  value = pair[1]

  new(name, value)
end
new(name, value = nil) click to toggle source

Constructor

@param name [String] @param optional value [String]

# File lib/percona_migrator/option.rb, line 22
def initialize(name, value = nil)
  @name = name
  @value = value
end

Public Instance Methods

==(another_option) click to toggle source

Compares two options

@param [Option] @return [Boolean]

# File lib/percona_migrator/option.rb, line 31
def ==(another_option)
  name == another_option.name
end
Also aliased as: eql?
eql?(another_option)
Alias for: ==
hash() click to toggle source

Returns the option's hash

@return [Fixnum]

# File lib/percona_migrator/option.rb, line 39
def hash
  name.hash
end
to_s() click to toggle source

Returns the option as string following the “–<name>=<value>” format

@return [String]

# File lib/percona_migrator/option.rb, line 46
def to_s
  "--#{name}#{value_as_string}"
end

Private Instance Methods

value_as_string() click to toggle source

Returns the value fragment of the option string if any value is specified

@return [String]

# File lib/percona_migrator/option.rb, line 55
def value_as_string
  if value.nil?
    ''
  else
    "=#{value}"
  end
end