Class: Envandle::Argset
- Inherits:
-
Object
- Object
- Envandle::Argset
- Defined in:
- lib/envandle/argset.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #args_and_options ⇒ Object
- #clear_reference ⇒ Object
- #contextual_groups ⇒ Object
- #dup ⇒ Object
- #get_contexutual_groups ⇒ Object
-
#initialize(context, *args, &block) ⇒ Argset
constructor
A new instance of Argset.
- #send_to(o) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(context, *args, &block) ⇒ Argset
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/envandle/argset.rb', line 3 def initialize(context, *args, &block) @context = context @args = args h = Envandle.(args) = {} h.each do |k, v| [k.to_s.to_sym] = v end @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
14 15 16 |
# File 'lib/envandle/argset.rb', line 14 def args @args end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
14 15 16 |
# File 'lib/envandle/argset.rb', line 14 def block @block end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/envandle/argset.rb', line 14 def end |
Instance Method Details
#args_and_options ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/envandle/argset.rb', line 30 def ||= begin if .empty? [*@args] else [*@args, ] end end end |
#clear_reference ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/envandle/argset.rb', line 20 def clear_reference @args = [@args[0]] .delete :path .delete :git .delete :github .delete :ref .delete :branch .delete :tag end |
#contextual_groups ⇒ Object
50 51 52 |
# File 'lib/envandle/argset.rb', line 50 def contextual_groups @contextual_groups ||= get_contexutual_groups end |
#dup ⇒ Object
16 17 18 |
# File 'lib/envandle/argset.rb', line 16 def dup Argset.new(@context, *@args.dup, .dup, &@block) end |
#get_contexutual_groups ⇒ Object
54 55 56 57 58 59 |
# File 'lib/envandle/argset.rb', line 54 def get_contexutual_groups if option = [:groups] || [:group] return option.is_a?(Array) ? option : [option] end @context.groups_or_default end |
#send_to(o) ⇒ Object
46 47 48 |
# File 'lib/envandle/argset.rb', line 46 def send_to(o) o.__send__ @context, *, &@block end |
#to_s ⇒ Object
40 41 42 43 44 |
# File 'lib/envandle/argset.rb', line 40 def to_s a = [@context, *] a << @block if @block a.to_s end |