module Hanoi::Jane

Constants

VERSION

Public Class Methods

draw_console(stacks, value, fancy = false) click to toggle source
# File lib/hanoi/jane.rb, line 63
def self.draw_console stacks, value, fancy = false
  system('clear')

  c = Formatters::Console.new do |c|
    c.stacks = stacks
    c.fancy = fancy
  end

  puts value
  puts c
end
hit_phat(grid, phat) click to toggle source
# File lib/hanoi/jane.rb, line 43
def self.hit_phat grid, phat
  url = "http://#{phat}/lights"
  payload = {
    matrix: grid
  }
  headers = {
    'Content-Type' => 'application/json',
    'Accept' => 'application/json'
  }

  HTTParty.patch(url, body: payload.to_json, headers: headers)
end
interval_factor(frame) click to toggle source
# File lib/hanoi/jane.rb, line 75
def self.interval_factor frame
  if frame.animtype == :tween
    return Config.instance.config.animation['tween-scale']
  end
  1
end
render_to_console(source, interval, fancy) click to toggle source
# File lib/hanoi/jane.rb, line 56
def self.render_to_console source, interval, fancy
  source.each do |frame|
    Hanoi::Jane.draw_console frame.stacks, frame.value, fancy
    sleep interval * interval_factor(frame)
  end
end
render_to_github(towers) click to toggle source
# File lib/hanoi/jane.rb, line 32
def self.render_to_github towers
  g = Formatters::Github.new towers
end
render_to_phat(source, interval, phat) click to toggle source
# File lib/hanoi/jane.rb, line 36
def self.render_to_phat source, interval, phat
  source.each do |frame|
    Hanoi::Jane.hit_phat frame.to_dots, phat
    sleep interval * interval_factor(frame)
  end
end
scale(size) click to toggle source
# File lib/hanoi/jane.rb, line 82
def self.scale size
  (size * 2) + 1
end