Class: HammerCLI::Output::Adapter::Abstract
- Inherits:
-
Object
- Object
- HammerCLI::Output::Adapter::Abstract
show all
- Defined in:
- lib/hammer_cli/output/adapter/abstract.rb
Instance Method Summary
collapse
Constructor Details
#initialize(context = {}, formatters = {}, filters = {}) ⇒ Abstract
Returns a new instance of Abstract.
15
16
17
18
19
20
21
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 15
def initialize(context={}, formatters={}, filters = {})
context[:verbosity] ||= HammerCLI::V_VERBOSE
@context = context
@formatters = HammerCLI::Output::Formatters::FormatterLibrary.new(filter_formatters(formatters))
@paginate_by_default = true
@filters = filters
end
|
Instance Method Details
#features ⇒ Object
9
10
11
12
13
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 9
def features
return %i[] if tags.empty?
tags.map { |t| HammerCLI::Output::Utils.tag_to_feature(t) }
end
|
#paginate_by_default? ⇒ Boolean
23
24
25
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 23
def paginate_by_default?
!!@paginate_by_default
end
|
#print_collection(fields, collection, options = {}) ⇒ Object
47
48
49
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 47
def print_collection(fields, collection, options = {})
raise NotImplementedError
end
|
#print_error(msg, details = nil, msg_params = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 31
def print_error(msg, details=nil, msg_params={})
details = details.split("\n") if details.kind_of? String
if details
indent = " "
msg += ":\n"
msg += indent + details.join("\n"+indent)
end
$stderr.puts msg.format(msg_params)
end
|
#print_message(msg, msg_params = {}) ⇒ Object
27
28
29
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 27
def print_message(msg, msg_params={})
puts msg.format(msg_params)
end
|
#print_record(fields, record) ⇒ Object
43
44
45
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 43
def print_record(fields, record)
raise NotImplementedError
end
|
5
6
7
|
# File 'lib/hammer_cli/output/adapter/abstract.rb', line 5
def tags
%i[]
end
|