class Nineteen::Eighty::Two::Spectrum

Constants

CHARACTERS

Public Class Methods

[](*text) click to toggle source
# File lib/nineteen/eighty/two/spectrum.rb, line 7
def self.[] *text
  a = []
  text.each do |t|
    a += Spectrum.linify(t.chars.map { |c| Spectrum.get(c) })
  end

  a
end
bits(number) click to toggle source
# File lib/nineteen/eighty/two/spectrum.rb, line 31
def self.bits number
  (0..7).map do |i|
    number[i]
  end.reverse
end
get(key) click to toggle source
# File lib/nineteen/eighty/two/spectrum.rb, line 26
def self.get key
  key = ' ' unless CHARACTERS[key]
  CHARACTERS[key].map { |b| Spectrum.bits(b) }
end
linify(*list) click to toggle source
# File lib/nineteen/eighty/two/spectrum.rb, line 37
def self.linify *list
  Matrix.columns(list.first).to_a.map { |l| l.flatten }
end
to_h() click to toggle source
# File lib/nineteen/eighty/two/spectrum.rb, line 16
def self.to_h
  h = {}

  CHARACTERS.keys.each do |c|
    h[c.to_sym] = get(c)
  end

  h
end