Skip to content

Commit

Permalink
Extract the coordinate procs to a shared location
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamMcCumstie committed Aug 17, 2020
1 parent ab35491 commit 9c5ca67
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/flight_asset/commands/concerns/has_asset_containers_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ module Commands
module Concerns
module HasAssetContainersRecord
extend ActiveSupport::Concern
XY_COORDINATE_PROCS = [
['X Position', ->(a) { "#{a.xStartPosition} - #{a.xEndPosition}" }],
['Y Position', ->(a) { "#{a.yStartPosition} - #{a.yEndPosition}" }]
]
VERBOSE_XY_COORDINATE_PROCS = [
[nil, ->(a) { a.xStartPosition }],
[nil, ->(a) { a.xEndPosition }],
[nil, ->(a) { a.yStartPosition }],
[nil, ->(a) { a.yEndPosition }]
]

included do
after(if: :tty?) do
Expand Down Expand Up @@ -79,8 +89,7 @@ def container_procs
def tty_parent_container_procs
[
['Location', ->(a) { "#{a.parentContainer.containerType} - #{a.parentContainer.name}" }],
['X Position', ->(a) { "#{a.xStartPosition} - #{a.xEndPosition}" }],
['Y Position', ->(a) { "#{a.yStartPosition} - #{a.yEndPosition}" }]
*XY_COORDINATE_PROCS
]
end

Expand All @@ -91,10 +100,7 @@ def non_tty_parent_container_procs
[
[nil, ->(a) { a.parentContainer.name }],
[nil, ->(a) { a.parentContainer.containerType }],
[nil, ->(a) { a.xStartPosition }],
[nil, ->(a) { a.xEndPosition }],
[nil, ->(a) { a.yStartPosition }],
[nil, ->(a) { a.yEndPosition }]
*VERBOSE_XY_COORDINATE_PROCS
]
end

Expand All @@ -103,8 +109,7 @@ def non_tty_parent_container_procs
def tty_child_container_procs
[
['Location', ->(a) { "#{a.containerType} - #{a.name}" }],
['X Position', ->(a) { "#{a.xStartPosition} - #{a.xEndPosition}" }],
['Y Position', ->(a) { "#{a.yStartPosition} - #{a.yEndPosition}" }]
*XY_COORDINATE_PROCS
]
end

Expand All @@ -114,10 +119,7 @@ def non_tty_child_container_procs
[
[nil, ->(a) { a.name }],
[nil, ->(a) { a.containerType }],
[nil, ->(a) { a.xStartPosition }],
[nil, ->(a) { a.xEndPosition }],
[nil, ->(a) { a.yStartPosition }],
[nil, ->(a) { a.yEndPosition }]
*VERBOSE_XY_COORDINATE_PROCS
]
end

Expand All @@ -126,8 +128,7 @@ def non_tty_child_container_procs
def tty_asset_procs
[
['Location', ->(a) { "asset - #{a.name}" }],
['X Position', ->(a) { "#{a.xStartPosition} - #{a.xEndPosition}" }],
['Y Position', ->(a) { "#{a.yStartPosition} - #{a.yEndPosition}" }]
*XY_COORDINATE_PROCS
]
end

Expand All @@ -137,10 +138,7 @@ def non_tty_asset_procs
[
[nil, ->(a) { a.name }],
[nil, ->(_) { 'asset' }],
[nil, ->(a) { a.xStartPosition }],
[nil, ->(a) { a.xEndPosition }],
[nil, ->(a) { a.yStartPosition }],
[nil, ->(a) { a.yEndPosition }]
*VERBOSE_XY_COORDINATE_PROCS
]
end
end
Expand Down

0 comments on commit 9c5ca67

Please sign in to comment.