Module: Lino::Options
Instance Method Summary
collapse
Methods included from Utilities
#empty?, #join_with, #map_and_join, #nil?, #nil_or_empty?, #quote_with
Instance Method Details
#with_flag(flag) ⇒ Object
60
61
62
63
64
|
# File 'lib/lino/options.rb', line 60
def with_flag(flag)
return self if nil?(flag)
with(options: @options.add({ components: [flag] }))
end
|
#with_flags(flags) ⇒ Object
66
67
68
69
70
|
# File 'lib/lino/options.rb', line 66
def with_flags(flags)
return self if nil_or_empty?(flags)
flags.inject(self) { |s, flag| s.with_flag(flag) }
end
|
#with_option(option, value, separator: nil, quoting: nil, placement: nil) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/lino/options.rb', line 9
def with_option(
option,
value,
separator: nil,
quoting: nil,
placement: nil
)
return self if nil?(value)
with(options: @options.add(
{
components: [option, value],
separator: separator,
quoting: quoting,
placement: placement
}
))
end
|
#with_options(options) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/lino/options.rb', line 28
def with_options(options)
return self if nil_or_empty?(options)
options.entries.inject(self) do |s, entry|
s.with_option(
or_nth(entry, :option, 0),
or_nth(entry, :value, 1),
separator: or_nil(entry, :separator),
quoting: or_nil(entry, :quoting),
placement: or_nil(entry, :placement)
)
end
end
|
#with_repeated_option(option, values, separator: nil, quoting: nil, placement: nil) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/lino/options.rb', line 42
def with_repeated_option(
option,
values,
separator: nil,
quoting: nil,
placement: nil
)
values.inject(self) do |s, value|
s.with_option(
option,
value,
separator: separator,
quoting: quoting,
placement: placement
)
end
end
|