Class: Nexter::Compass

Inherits:
Object
  • Object
show all
Defined in:
lib/nexter/compass.rb

Constant Summary collapse

DIREC =
{asc: 1, desc: -1}
GOTO =
{next: 1, previous: -1}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(goto) ⇒ Compass

Returns a new instance of Compass.



12
13
14
# File 'lib/nexter/compass.rb', line 12

def initialize(goto)
  @goto = goto
end

Instance Attribute Details

#directionObject

Returns the value of attribute direction.



7
8
9
# File 'lib/nexter/compass.rb', line 7

def direction
  @direction
end

#gotoObject

Returns the value of attribute goto.



7
8
9
# File 'lib/nexter/compass.rb', line 7

def goto
  @goto
end

Instance Method Details

#bracketObject



16
17
18
# File 'lib/nexter/compass.rb', line 16

def bracket
  sign == -1 ? '<' : '>'
end

#redirectionObject



20
21
22
# File 'lib/nexter/compass.rb', line 20

def redirection
  sign == -1 ? 'DESC' : 'ASC'
end

#signObject



24
25
26
# File 'lib/nexter/compass.rb', line 24

def sign
  DIREC[direction.downcase.to_sym] * GOTO[goto]
end