class Rubedility::Lesson
Attributes
lesson_url[RW]
name[RW]
number[RW]
reading_url[RW]
tests_solved[RW]
tests_started[RW]
Public Class Methods
all()
click to toggle source
# File lib/rubedility/lesson.rb, line 20 def self.all @@all end
display_all()
click to toggle source
# File lib/rubedility/lesson.rb, line 43 def self.display_all puts "\nAvailable Lessons: \n" self.all.each do |les| puts "#{les.number}. #{les.name}" end puts "\n" return nil end
new(lesson_hash)
click to toggle source
# File lib/rubedility/lesson.rb, line 6 def initialize(lesson_hash) add_lesson_attributes(lesson_hash) @tasks = [] @@all.push(self) end
populate_from_scraping(lessons_array)
click to toggle source
# File lib/rubedility/lesson.rb, line 14 def self.populate_from_scraping(lessons_array) lessons_array.each do |lesson| self.new(lesson) end end
user_display_one()
click to toggle source
# File lib/rubedility/lesson.rb, line 24 def self.user_display_one self.display_all print "Select Lesson Number:" input = gets.strip.to_i self.all.each do |lesson| if lesson.number==input lesson.display_lesson return nil end end puts "Try selecting a correct number next time." end
user_display_stats()
click to toggle source
# File lib/rubedility/lesson.rb, line 52 def self.user_display_stats self.display_all print "Select Lesson Number for stats:" input = gets.strip.to_i self.all.each do |lesson| if lesson.number==input lesson.display_stats return nil end end return "Try selecting a correct number next time." end
user_open_reading()
click to toggle source
# File lib/rubedility/lesson.rb, line 71 def self.user_open_reading self.display_all print "Select Lesson Number for reading:" input = gets.strip.to_i self.all.each do |lesson| if lesson.number==input #lesson.open_reading return lesson.reading_url end end return "Try selecting a correct number next time." end
Public Instance Methods
add_lesson_attributes(attributes_hash)
click to toggle source
# File lib/rubedility/lesson.rb, line 99 def add_lesson_attributes(attributes_hash) if attributes_hash == nil return end attributes_hash.each{|key, val| self.send(("#{key}="), val)} end
add_tasks(task_array)
click to toggle source
# File lib/rubedility/lesson.rb, line 89 def add_tasks(task_array) task_array.each do |task_row| self.tasks.push(Rubedility::Task.new(task_row)) end end
display_lesson()
click to toggle source
# File lib/rubedility/lesson.rb, line 37 def display_lesson self.tasks.each do |task| task.display_row end end
display_stats()
click to toggle source
# File lib/rubedility/lesson.rb, line 65 def display_stats puts "\n#{self.tests_started} tests have been started from this lesson." puts "#{self.tests_solved} tests have been solved from this lesson." puts "#{self.tasks.length} task(s) gives an average success rate of #{(self.tests_solved.to_f/self.tests_started.to_f).round(3)*100}%" end
open_reading()
click to toggle source
# File lib/rubedility/lesson.rb, line 84 def open_reading puts "launchy: #{@reading_url}" launchy @reading_url end
tasks()
click to toggle source
# File lib/rubedility/lesson.rb, line 95 def tasks @tasks end