Class: GitCommander::Command::Option Abstract
- Inherits:
-
Object
- Object
- GitCommander::Command::Option
- Defined in:
- lib/git_commander/command/option.rb
Overview
This class is abstract.
Wraps [Command] arguments, flags, and switches in a generic object to normalize their representation in the context of a [Command].
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
- #value ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(name:, default: nil, description: nil, value: nil) ⇒ Option
constructor
Creates a [Option] object.
- #to_h ⇒ Object
Constructor Details
#initialize(name:, default: nil, description: nil, value: nil) ⇒ Option
Creates a [Option] object.
19 20 21 22 23 24 |
# File 'lib/git_commander/command/option.rb', line 19 def initialize(name:, default: nil, description: nil, value: nil) @name = name.to_sym @default = default @description = description @value = value end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
9 10 11 |
# File 'lib/git_commander/command/option.rb', line 9 def default @default end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/git_commander/command/option.rb', line 9 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/git_commander/command/option.rb', line 9 def name @name end |
#value ⇒ Object
26 27 28 |
# File 'lib/git_commander/command/option.rb', line 26 def value @value || @default end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
30 31 32 33 34 35 |
# File 'lib/git_commander/command/option.rb', line 30 def ==(other) other.class == self.class && other.name == name && other.default == default && other.description == description end |
#to_h ⇒ Object
38 39 40 |
# File 'lib/git_commander/command/option.rb', line 38 def to_h { name => value } end |