Class: Main::Parameter::DSL
Instance Attribute Summary collapse
-
#p ⇒ Object
readonly
Returns the value of attribute p.
Class Method Summary collapse
Instance Method Summary collapse
- #argument(arg) ⇒ Object
- #argument_optional(bool = true) ⇒ Object
- #argument_optional? ⇒ Boolean
- #argument_required(bool = true) ⇒ Object
- #argument_required? ⇒ Boolean
- #arity(value) ⇒ Object
- #arity? ⇒ Boolean
- #cast(sym = nil, &b) ⇒ Object
- #cast? ⇒ Boolean
- #default(value, *values) ⇒ Object
- #defaults(value, *values) ⇒ Object
- #defaults? ⇒ Boolean
- #description(s) ⇒ Object (also: #desc)
- #description? ⇒ Boolean
- #error(which = :error, &block) ⇒ Object
-
#initialize(param) ⇒ DSL
constructor
A new instance of DSL.
- #optional(bool = true) ⇒ Object
- #optional? ⇒ Boolean
- #required(bool = true) ⇒ Object
- #required? ⇒ Boolean
- #synopsis(arg) ⇒ Object
- #type(sym) ⇒ Object
- #type? ⇒ Boolean
- #validate(sym = nil, &b) ⇒ Object
- #validate? ⇒ Boolean
Constructor Details
#initialize(param) ⇒ DSL
Returns a new instance of DSL.
459 460 461 |
# File 'lib/main/parameter.rb', line 459 def initialize param @p = param end |
Instance Attribute Details
#p ⇒ Object (readonly)
Returns the value of attribute p.
457 458 459 |
# File 'lib/main/parameter.rb', line 457 def p @p end |
Class Method Details
.evaluate(param, &block) ⇒ Object
454 455 456 |
# File 'lib/main/parameter.rb', line 454 def self.evaluate param, &block new(param).evaluate(&block) end |
Instance Method Details
#argument(arg) ⇒ Object
474 475 476 |
# File 'lib/main/parameter.rb', line 474 def argument arg p.argument arg end |
#argument_optional(bool = true) ⇒ Object
488 489 490 491 492 493 494 |
# File 'lib/main/parameter.rb', line 488 def argument_optional bool = true if bool p.argument :optional else p.argument false end end |
#argument_optional? ⇒ Boolean
495 496 497 |
# File 'lib/main/parameter.rb', line 495 def argument_optional? p.argument_optional? end |
#argument_required(bool = true) ⇒ Object
477 478 479 480 481 482 483 |
# File 'lib/main/parameter.rb', line 477 def argument_required bool = true if bool p.argument :required else p.argument false end end |
#argument_required? ⇒ Boolean
484 485 486 |
# File 'lib/main/parameter.rb', line 484 def argument_required? p.argument_required? end |
#arity(value) ⇒ Object
556 557 558 559 |
# File 'lib/main/parameter.rb', line 556 def arity value value = -1 if value.to_s == '*' p.arity = Integer value end |
#arity? ⇒ Boolean
560 561 562 |
# File 'lib/main/parameter.rb', line 560 def arity? p.arity? end |
#cast(sym = nil, &b) ⇒ Object
517 518 519 |
# File 'lib/main/parameter.rb', line 517 def cast sym=nil, &b p.cast = sym || b end |
#cast? ⇒ Boolean
520 521 522 |
# File 'lib/main/parameter.rb', line 520 def cast? p.cast? end |
#default(value, *values) ⇒ Object
539 540 541 542 543 |
# File 'lib/main/parameter.rb', line 539 def default value, *values p.defaults.push value p.defaults.push *values p.defaults end |
#defaults(value, *values) ⇒ Object
547 548 549 550 551 |
# File 'lib/main/parameter.rb', line 547 def defaults value, *values p.defaults.push value p.defaults.push *values p.defaults end |
#defaults? ⇒ Boolean
544 545 546 |
# File 'lib/main/parameter.rb', line 544 def defaults? p.defaults? end |
#description(s) ⇒ Object Also known as: desc
531 532 533 |
# File 'lib/main/parameter.rb', line 531 def description s p.description = s.to_s end |
#description? ⇒ Boolean
534 535 536 |
# File 'lib/main/parameter.rb', line 534 def description? p.description? end |
#error(which = :error, &block) ⇒ Object
564 565 566 |
# File 'lib/main/parameter.rb', line 564 def error which = :error, &block p.send "#{ which }_handler=", block end |
#optional(bool = true) ⇒ Object
506 507 508 509 510 511 512 |
# File 'lib/main/parameter.rb', line 506 def optional bool = true if bool p.required !bool else p.required bool end end |
#optional? ⇒ Boolean
513 514 515 |
# File 'lib/main/parameter.rb', line 513 def optional? p.optional? end |
#required(bool = true) ⇒ Object
499 500 501 |
# File 'lib/main/parameter.rb', line 499 def required bool = true p.required = bool end |
#required? ⇒ Boolean
502 503 504 |
# File 'lib/main/parameter.rb', line 502 def required? p.required? end |
#synopsis(arg) ⇒ Object
470 471 472 |
# File 'lib/main/parameter.rb', line 470 def synopsis arg p.synopsis arg end |
#type(sym) ⇒ Object
463 464 465 |
# File 'lib/main/parameter.rb', line 463 def type sym p.type = sym end |
#type? ⇒ Boolean
466 467 468 |
# File 'lib/main/parameter.rb', line 466 def type? p.type? end |
#validate(sym = nil, &b) ⇒ Object
524 525 526 |
# File 'lib/main/parameter.rb', line 524 def validate sym=nil, &b p.validate = sym || b end |
#validate? ⇒ Boolean
527 528 529 |
# File 'lib/main/parameter.rb', line 527 def validate? p.validate? end |