Class: Opt::Command::Result
- Inherits:
-
Hash
- Object
- Hash
- Opt::Command::Result
- Defined in:
- lib/opt/command.rb
Overview
A hash-like result object.
Allow for method-access to all key-value pairs similar to ‘OpenStruct`.
Instance Attribute Summary collapse
-
#command ⇒ Array<String>
readonly
A list of command names.
Instance Method Summary collapse
-
#initialize ⇒ Result
constructor
private
A new instance of Result.
- #method_missing(mth, *args, &block) ⇒ Object private
- #respond_to_missing?(mth) ⇒ Boolean private
Constructor Details
#initialize ⇒ Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Result.
229 230 231 232 |
# File 'lib/opt/command.rb', line 229 def initialize @command = [] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mth, *args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
246 247 248 249 250 251 252 |
# File 'lib/opt/command.rb', line 246 def method_missing(mth, *args, &block) if mth =~ /^(\w+)\??$/ && key?($1) && args.empty? && block.nil? fetch $1 else super end end |
Instance Attribute Details
#command ⇒ Array<String> (readonly)
A list of command names.
225 226 227 |
# File 'lib/opt/command.rb', line 225 def command @command end |
Instance Method Details
#respond_to_missing?(mth) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
236 237 238 239 240 241 242 |
# File 'lib/opt/command.rb', line 236 def respond_to_missing?(mth) if mth =~ /^(\w)\??$/ && key?($1) true else super end end |