Module: Clue::Arguments

Included in:
Clue
Defined in:
lib/clue/arguments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



2
3
4
# File 'lib/clue/arguments.rb', line 2

def arguments
  @arguments
end

Instance Method Details

#add_argument(arg) ⇒ Object

Add one argument



23
24
25
26
# File 'lib/clue/arguments.rb', line 23

def add_argument(arg)
  @arguments << arg
  @arguments.uniq!
end

#add_arguments(args) ⇒ Object

Add many arguemnts



29
30
31
32
33
34
35
# File 'lib/clue/arguments.rb', line 29

def add_arguments(args)
  return unless args
  args = args.split(' ') if args.is_a?(String)

  @arguments += args.map(&:to_s)
  @arguments.uniq!
end

#cli_argumentsObject

Returns a string or arguments suitable for cli use



38
39
40
# File 'lib/clue/arguments.rb', line 38

def cli_arguments
  @arguments.join self.config[:between_arguments]
end

#init_arguments(args = nil) ⇒ Object

Initialize arguments ivars



5
6
7
8
9
# File 'lib/clue/arguments.rb', line 5

def init_arguments(args = nil)
  @arguments = []

  parse_arguments(args)
end

#parse_arguments(value = []) ⇒ Object

Parse “classic” arguments



12
13
14
15
16
17
18
19
20
# File 'lib/clue/arguments.rb', line 12

def parse_arguments(value = [])
  return unless value

  if value.kind_of?(String) || value.kind_of?(Symbol)
    value = [value]
  end

  @arguments = value
end