Class: PerconaMigrator::Option
- Inherits:
-
Object
- Object
- PerconaMigrator::Option
- Defined in:
- lib/percona_migrator/option.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_string(string) ⇒ Option
Builds an instance by parsing its name and value out of the given string.
Instance Method Summary collapse
-
#==(another_option) ⇒ Boolean
(also: #eql?)
Compares two options.
-
#hash ⇒ Fixnum
Returns the option’s hash.
-
#initialize(name, value = nil) ⇒ Option
constructor
Constructor.
-
#to_s ⇒ String
Returns the option as string following the “–<name>=<value>” format.
Constructor Details
#initialize(name, value = nil) ⇒ Option
Constructor
22 23 24 25 |
# File 'lib/percona_migrator/option.rb', line 22 def initialize(name, value = nil) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/percona_migrator/option.rb', line 3 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/percona_migrator/option.rb', line 3 def value @value end |
Class Method Details
.from_string(string) ⇒ Option
Builds an instance by parsing its name and value out of the given string. Note the string must conform to “–<arg>=<value>” format.
10 11 12 13 14 15 16 |
# 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 |
Instance Method Details
#==(another_option) ⇒ Boolean Also known as: eql?
Compares two options
31 32 33 |
# File 'lib/percona_migrator/option.rb', line 31 def ==(another_option) name == another_option.name end |
#hash ⇒ Fixnum
Returns the option’s hash
39 40 41 |
# File 'lib/percona_migrator/option.rb', line 39 def hash name.hash end |
#to_s ⇒ String
Returns the option as string following the “–<name>=<value>” format
46 47 48 |
# File 'lib/percona_migrator/option.rb', line 46 def to_s "--#{name}#{value_as_string}" end |