Class: MetadataPresenter::Coordinates
- Inherits:
-
Object
- Object
- MetadataPresenter::Coordinates
show all
- Includes:
- BranchDestinations
- Defined in:
- app/models/metadata_presenter/coordinates.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#exiting_destinations_from_branch, #has_or_conditionals?
Constructor Details
#initialize(service) ⇒ Coordinates
Returns a new instance of Coordinates.
5
6
7
8
9
|
# File 'app/models/metadata_presenter/coordinates.rb', line 5
def initialize(service)
@service = service
@positions = setup_positions
@branch_spacers = setup_branch_spacers
end
|
Instance Attribute Details
#branch_spacers ⇒ Object
Returns the value of attribute branch_spacers.
11
12
13
|
# File 'app/models/metadata_presenter/coordinates.rb', line 11
def branch_spacers
@branch_spacers
end
|
#positions ⇒ Object
Returns the value of attribute positions.
11
12
13
|
# File 'app/models/metadata_presenter/coordinates.rb', line 11
def positions
@positions
end
|
Instance Method Details
#positions_in_column(column_number) ⇒ Object
37
38
39
|
# File 'app/models/metadata_presenter/coordinates.rb', line 37
def positions_in_column(column_number)
positions.select { |_, position| position[:column] == column_number }
end
|
#set_branch_spacers_column(branch_uuid, column) ⇒ Object
41
42
43
44
45
|
# File 'app/models/metadata_presenter/coordinates.rb', line 41
def set_branch_spacers_column(branch_uuid, column)
branch_spacers[branch_uuid].each do |position|
position[:column] = column
end
end
|
#set_branch_spacers_row(branch_uuid, starting_row) ⇒ Object
The first conditional will always attempt to draw an arrow on the same row as the branch object. Each following conditional needs to have a spacers in order for the frontend to draw an arrow therefore we increment the row number from the branches calculated starting row
52
53
54
55
56
|
# File 'app/models/metadata_presenter/coordinates.rb', line 52
def set_branch_spacers_row(branch_uuid, starting_row)
branch_spacers[branch_uuid].each.with_index(starting_row) do |position, row|
position[:row] = row
end
end
|
#set_column(uuid, number) ⇒ Object
13
14
15
|
# File 'app/models/metadata_presenter/coordinates.rb', line 13
def set_column(uuid, number)
positions[uuid][:column] = number
end
|
#set_row(uuid, number) ⇒ Object
17
18
19
|
# File 'app/models/metadata_presenter/coordinates.rb', line 17
def set_row(uuid, number)
positions[uuid][:row] = number
end
|
#uuid_at_position(column, row) ⇒ Object
29
30
31
32
33
34
35
|
# File 'app/models/metadata_presenter/coordinates.rb', line 29
def uuid_at_position(column, row)
positions.find do |uuid, position|
if position[:column] == column && position[:row] == row
return uuid
end
end
end
|
#uuid_column(uuid) ⇒ Object
21
22
23
|
# File 'app/models/metadata_presenter/coordinates.rb', line 21
def uuid_column(uuid)
positions[uuid][:column]
end
|
#uuid_row(uuid) ⇒ Object
25
26
27
|
# File 'app/models/metadata_presenter/coordinates.rb', line 25
def uuid_row(uuid)
positions[uuid][:row]
end
|