Class: Voom::Parameters
- Inherits:
-
Object
- Object
- Voom::Parameters
- Defined in:
- lib/voom/parameters.rb
Overview
Provides a query interface for the ruby parameters method
Instance Method Summary collapse
- #args ⇒ Object
-
#initialize(parameters) ⇒ Parameters
constructor
A new instance of Parameters.
- #names(args_or_options) ⇒ Object
- #optional_args ⇒ Object
- #optional_args? ⇒ Boolean
- #optional_options ⇒ Object
- #optional_options? ⇒ Boolean
- #options ⇒ Object
- #options? ⇒ Boolean
- #required_args ⇒ Object
- #required_args? ⇒ Boolean
- #required_options ⇒ Object
- #required_options? ⇒ Boolean
- #spalts_options ⇒ Object
- #splats_args ⇒ Object
- #splats_args? ⇒ Boolean
- #splats_options? ⇒ Boolean
Constructor Details
#initialize(parameters) ⇒ Parameters
Returns a new instance of Parameters.
4 5 6 |
# File 'lib/voom/parameters.rb', line 4 def initialize(parameters) @params = parameters end |
Instance Method Details
#args ⇒ Object
8 9 10 |
# File 'lib/voom/parameters.rb', line 8 def args @params.select {|p| p.first == :req || p.first == :opt} end |
#names(args_or_options) ⇒ Object
69 70 71 |
# File 'lib/voom/parameters.rb', line 69 def names() .map(&:last) end |
#optional_args ⇒ Object
20 21 22 |
# File 'lib/voom/parameters.rb', line 20 def optional_args @params.select {|p| p.first == :opt} end |
#optional_args? ⇒ Boolean
24 25 26 |
# File 'lib/voom/parameters.rb', line 24 def optional_args? optional_args.any? end |
#optional_options ⇒ Object
53 54 55 |
# File 'lib/voom/parameters.rb', line 53 def @params.select {|p| p.first == :key} end |
#optional_options? ⇒ Boolean
57 58 59 |
# File 'lib/voom/parameters.rb', line 57 def .any? end |
#options ⇒ Object
36 37 38 |
# File 'lib/voom/parameters.rb', line 36 def @params.select {|p| p.first == :keyreq || p.first == :key} end |
#options? ⇒ Boolean
40 41 42 |
# File 'lib/voom/parameters.rb', line 40 def .any? end |
#required_args ⇒ Object
12 13 14 |
# File 'lib/voom/parameters.rb', line 12 def required_args @params.select {|p| p.first == :req} end |
#required_args? ⇒ Boolean
16 17 18 |
# File 'lib/voom/parameters.rb', line 16 def required_args? required_args.any? end |
#required_options ⇒ Object
44 45 46 |
# File 'lib/voom/parameters.rb', line 44 def @params.select {|p| p.first == :keyreq} end |
#required_options? ⇒ Boolean
48 49 50 |
# File 'lib/voom/parameters.rb', line 48 def .any? end |
#spalts_options ⇒ Object
61 62 63 |
# File 'lib/voom/parameters.rb', line 61 def @params.select {|p| p.first == :keyrest} end |
#splats_args ⇒ Object
28 29 30 |
# File 'lib/voom/parameters.rb', line 28 def splats_args @params.select {|p| p.first == :rest} end |
#splats_args? ⇒ Boolean
32 33 34 |
# File 'lib/voom/parameters.rb', line 32 def splats_args? splats_args.any? end |
#splats_options? ⇒ Boolean
65 66 67 |
# File 'lib/voom/parameters.rb', line 65 def .any? end |