class Savage::Direction
Public Class Methods
new(absolute)
click to toggle source
# File lib/savage/direction.rb, line 11 def initialize(absolute) @absolute = absolute end
Public Instance Methods
absolute?()
click to toggle source
# File lib/savage/direction.rb, line 15 def absolute? @absolute end
fully_transformable?()
click to toggle source
Public: determine if this direction is fully transformable.
A fully transformable directions can accept any transform including rotate.
Returns: true by default
# File lib/savage/direction.rb, line 33 def fully_transformable? true end
relative?()
click to toggle source
# File lib/savage/direction.rb, line 19 def relative? !absolute? end
to_command()
click to toggle source
# File lib/savage/direction.rb, line 23 def to_command arr = to_a arr[0] + arr[1..-1].map {|i| to_short_f(i)}.join(' ').gsub(/ -/,'-') end
Private Instance Methods
to_short_f(n)
click to toggle source
# File lib/savage/direction.rb, line 39 def to_short_f n f = 1000000.0 n = (n * f).round / f n == n.to_i ? n.to_i : n end