Class: AwsPublicIps::Formatters::Text
- Inherits:
-
Object
- Object
- AwsPublicIps::Formatters::Text
- Defined in:
- lib/aws_public_ips/formatters/text.rb
Instance Method Summary collapse
- #format ⇒ Object
- #format_normal ⇒ Object
- #format_verbose ⇒ Object
-
#initialize(results, options) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(results, options) ⇒ Text
Returns a new instance of Text.
6 7 8 9 |
# File 'lib/aws_public_ips/formatters/text.rb', line 6 def initialize(results, ) @results = results @options = end |
Instance Method Details
#format ⇒ Object
11 12 13 14 |
# File 'lib/aws_public_ips/formatters/text.rb', line 11 def format lines = @options[:verbose] ? format_verbose : format_normal lines.uniq.join("\n") end |
#format_normal ⇒ Object
16 17 18 19 20 |
# File 'lib/aws_public_ips/formatters/text.rb', line 16 def format_normal @results.values.flatten.flat_map do |hash| hash[:ip_addresses] end end |
#format_verbose ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aws_public_ips/formatters/text.rb', line 22 def format_verbose @results.flat_map do |service, hashes| next [] if hashes.empty? ["## #{service}"] + hashes.flat_map do |hash| [hash[:id], hash[:hostname]].compact.map do |line| "# #{line}" end + hash[:ip_addresses] end end end |