class Shrift

Making short shrift of Objects.

Attributes

clazz[R]

Public Class Methods

new(clazz, guide = []) click to toggle source
# File lib/shrift.rb, line 11
def initialize(clazz, guide = [])
  @clazz = clazz
  @guide = guide
end

Public Instance Methods

classify(shrift_string) click to toggle source
# File lib/shrift.rb, line 21
def classify(shrift_string)
  zippy = @guide.zip(shrift_string.split(':'))
  objective = Object.const_get(clazz.to_s).new

  zippy.each do |cell|
    cell[0].set(cell[1], objective)
  end

  objective
end
short(target) click to toggle source

Turns the target class into a Shrift String

# File lib/shrift.rb, line 17
def short(target)
  @guide.map { |cell| cell.process(target) }.join(':')
end