Class: Clyops::Values

Inherits:
Hash
  • Object
show all
Defined in:
lib/clyops.rb

Overview

Resolved values: keys are option vars and argument names, also readable as methods (args.PORT).

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ String, ...

Read a resolved key as a method; unknown names raise NoMethodError.

Returns:

  • (String, Integer, Float, Boolean, Array, nil)


367
368
369
370
371
372
# File 'lib/clyops.rb', line 367

def method_missing(name, *args)
  key = name.to_s
  return self[key] if args.empty? && key?(key)

  super
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Whether the requested name is a resolved key or an inherited method.

Returns:

  • (Boolean)


376
# File 'lib/clyops.rb', line 376

def respond_to_missing?(name, include_private = false) = key?(name.to_s) || super