Class: HammerCLI::Output::Adapter::TreeStructure
- Inherits:
-
Abstract
- Object
- Abstract
- HammerCLI::Output::Adapter::TreeStructure
show all
- Defined in:
- lib/hammer_cli/output/adapter/tree_structure.rb
Instance Method Summary
collapse
Methods inherited from Abstract
#paginate_by_default?, #print_collection, #print_error, #print_message, #print_record, #tags
Constructor Details
#initialize(context = {}, formatters = {}, filters = {}) ⇒ TreeStructure
Returns a new instance of TreeStructure.
3
4
5
6
|
# File 'lib/hammer_cli/output/adapter/tree_structure.rb', line 3
def initialize(context = {}, formatters = {}, filters = {})
super
@paginate_by_default = false
end
|
Instance Method Details
#features ⇒ Object
8
9
10
11
12
|
# File 'lib/hammer_cli/output/adapter/tree_structure.rb', line 8
def features
return %i[structured] if tags.empty?
tags.map { |t| HammerCLI::Output::Utils.tag_to_feature(t) }
end
|
#prepare_collection(fields, collection) ⇒ Object
14
15
16
17
18
|
# File 'lib/hammer_cli/output/adapter/tree_structure.rb', line 14
def prepare_collection(fields, collection)
collection.map do |element|
render_fields(fields, element)
end
end
|
#prepare_message(msg, msg_params = {}) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/hammer_cli/output/adapter/tree_structure.rb', line 20
def prepare_message(msg, msg_params = {})
data = {
capitalize(:message) => msg.format(msg_params)
}
return data if msg_params.nil?
id = msg_params['id'] || msg_params[:id]
name = msg_params['name'] || msg_params[:name]
data[capitalize(:id)] = id unless id.nil?
data[capitalize(:name)] = name unless name.nil?
data
end
|