Class: Tabry::Models::Sub
Constant Summary
collapse
- FIELDS =
{
aliases: :string_array,
args: [:list_object, :ArgsList],
description: :string,
flags: [:list_object, :FlagsList],
name: :string,
subs: [:list_object, :SubsList],
}.freeze
Instance Attribute Summary
Attributes inherited from ConfigObject
#_raw, #_root
Class Method Summary
collapse
Instance Method Summary
collapse
as_json, #as_json, #assert_of_class, #init_field_boolean, #init_field_list_object, #init_field_object, #init_field_string, #init_field_string_array, #initialize, #inspect, #to_s
Class Method Details
.new(**args) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/tabry/models/sub.rb', line 11
def self.new(**args)
hash = args[:raw]
if hash["include"]
IncludeSub.new(**args)
else
super(**args)
end
end
|
Instance Method Details
#args ⇒ Object
40
41
42
|
# File 'lib/tabry/models/sub.rb', line 40
def args
@args ||= ArgsList.new(raw: [], root: _root)
end
|
#flags ⇒ Object
36
37
38
|
# File 'lib/tabry/models/sub.rb', line 36
def flags
@flags ||= FlagsList.new(raw: [], root: _root)
end
|
#flatten ⇒ Object
44
45
46
|
# File 'lib/tabry/models/sub.rb', line 44
def flatten
self
end
|
#max_args ⇒ Object
52
53
54
55
56
|
# File 'lib/tabry/models/sub.rb', line 52
def max_args
return Float::INFINITY if args.any?(&:varargs?)
args.count
end
|
#min_args ⇒ Object
48
49
50
|
# File 'lib/tabry/models/sub.rb', line 48
def min_args
args.reject(&:optional).count
end
|
#subs ⇒ Object
TODO: put this default stuff into ConfigObject
32
33
34
|
# File 'lib/tabry/models/sub.rb', line 32
def subs
@subs ||= SubsList.new(raw: [], root: _root)
end
|