Sha256: c04ec696c8316140f30a40dc9314bf951d7076af415827e1919f0c44369abddf

Contents?: true

Size: 930 Bytes

Versions: 1

Compression:

Stored size: 930 Bytes

Contents

class Course < Forgery
  attr_reader :name, :uid, :sis_id, :description
  @@local_dictionaries = File.absolute_path("lib")
  
  def initialize(name, uid, sis, desc)
    @name = name
    @uid = uid
    @sis_id = sis
    @description = desc
  end

  def to_s
    s = "#{@name}, #{@uid}, #{@sis_id}, #{@description}"
  end

  def self.set_prefix prefix
    @@prefix = prefix
  end

  def self.random
    Course.new(
      Course.course_name,
      Course.course_code,
      (12000+rand(1000000)).to_s,
      Course.description
    )
  end

  def self.course_code
    Forgery.load_from!(@@local_dictionaries)
    dictionaries[:course_codes][@@row]
  end

  def self.course_name
    Forgery.load_from!(@@local_dictionaries)
    name_count = Forgery.dictionaries[:course_names].count
    @@row = rand(name_count)
    dictionaries[:course_names][@@row]
  end

  def self.description
    Forgery(:lorem_ipsum).words(2+rand(30))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bobross-0.1.6 lib/models/course.rb