Class: ActiveKit::Position::Positioning

Inherits:
Object
  • Object
show all
Defined in:
lib/active_kit/position/positioning.rb

Constant Summary collapse

BASE =
36

Instance Method Summary collapse

Constructor Details

#initializePositioning

Returns a new instance of Positioning.



6
7
8
9
10
# File 'lib/active_kit/position/positioning.rb', line 6

def initialize
  @initial_tier = "t0"
  @initial_spot = "00"
  @initial_slot = "hz"
end

Instance Method Details

#chair_above(currvalue:) ⇒ Object



23
24
25
26
27
28
# File 'lib/active_kit/position/positioning.rb', line 23

def chair_above(currvalue:)
  currtier, currspot = currvalue.split("|").take(2)
  nicespot = (currspot.to_i(BASE) - 1).to_s(BASE).rjust(currspot.length, "0")
  nicespot = firstspot(currspot) if nicespot.to_i(BASE) == 0
  chair(currtier, nicespot, @initial_slot)
end

#chair_at(position:, tier_no:, total_count:, increase_spot_length_by:) ⇒ Object



16
17
18
19
20
21
# File 'lib/active_kit/position/positioning.rb', line 16

def chair_at(position:, tier_no:, total_count:, increase_spot_length_by:)
  nicetire = "t#{tier_no}"
  nicespot = (position - 1).to_s(BASE)
  nicespot = nicespot.rjust((total_count - 1).to_s(BASE).length + increase_spot_length_by, "0")
  chair(nicetire, nicespot, @initial_slot)
end

#chair_below(currvalue:) ⇒ Object



30
31
32
33
34
35
# File 'lib/active_kit/position/positioning.rb', line 30

def chair_below(currvalue:)
  currtier, currspot = currvalue.split("|").take(2)
  nicespot = (currspot.to_i(BASE) + 1).to_s(BASE).rjust(currspot.length, "0")
  nicespot = finalspot(currspot) if nicespot.to_i(BASE) > finalspot(currspot).to_i(BASE)
  chair(currtier, nicespot, @initial_slot)
end

#chair_firstObject



12
13
14
# File 'lib/active_kit/position/positioning.rb', line 12

def chair_first
  chair(@initial_tier, @initial_spot, @initial_slot)
end

#stool_above(currvalue:, prevvalue:) ⇒ Object



37
38
39
40
41
# File 'lib/active_kit/position/positioning.rb', line 37

def stool_above(currvalue:, prevvalue:)
  currtier, currspot, currslot = currvalue.split("|")
  prevtier, prevspot, prevslot = prevvalue.split("|") if prevvalue
  stool(currtier, currspot, firstslot(currtier, prevtier, currspot, prevspot, prevslot), currslot)
end

#stool_below(currvalue:, nextvalue:) ⇒ Object



43
44
45
46
47
# File 'lib/active_kit/position/positioning.rb', line 43

def stool_below(currvalue:, nextvalue:)
  currtier, currspot, currslot = currvalue.split("|")
  nexttier, nextspot, nextslot = nextvalue.split("|") if nextvalue
  stool(currtier, currspot, currslot, finalslot(currtier, nexttier, currspot, nextspot, nextslot))
end