Class: Archimate::Cli::Mapper
- Inherits:
-
Object
- Object
- Archimate::Cli::Mapper
- Defined in:
- lib/archimate/cli/mapper.rb
Constant Summary collapse
- HEADERS =
%w[id name viewpoint].freeze
- COL_DIVIDER =
" | "
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, output_io) ⇒ Mapper
constructor
A new instance of Mapper.
- #map ⇒ Object
Constructor Details
#initialize(model, output_io) ⇒ Mapper
Returns a new instance of Mapper.
11 12 13 14 |
# File 'lib/archimate/cli/mapper.rb', line 11 def initialize(model, output_io) @model = model @output = output_io end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'lib/archimate/cli/mapper.rb', line 9 def model @model end |
Instance Method Details
#map ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/archimate/cli/mapper.rb', line 16 def map widths = compute_column_widths(process_diagrams(model.diagrams), HEADERS) adjusted_widths = widths.inject(COL_DIVIDER.size * (HEADERS.size - 1), &:+) header_row(widths, HEADERS) organization_paths = build_organization_hash(model.organizations) organization_paths.keys.sort.each do |organization_name| diagrams = organization_paths[organization_name].select { |i| i.is_a?(DataModel::Diagram) } next if diagrams.empty? @output.puts(Color.color(format("%-#{adjusted_widths}s", organization_name), %i[bold green on_light_black])) output_diagrams(process_diagrams(diagrams), widths) end @output.puts "\n#{model.diagrams.size} Diagrams" end |