class CLI::PRO

Attributes

author[RW]
blurb[RW]
summary[RW]
title[RW]
url[RW]

Public Class Methods

list_details(index) click to toggle source
# File lib/prls/pro.rb, line 58
def self.list_details(index)
    puts ""
    puts "TITLE"
    puts ""
    puts "#{self.all[index].title} by #{self.all[index].author}"
    puts ""
    puts "SUMMARY"
    puts ""
    if self.all[index].summary == nil || self.all[index].summary == ""
        puts "No summary found."
    else
        puts self.all[index].summary.split.join(' ').wrap
    end
    puts ""
    puts "REVIEWS"
    puts ""
    if self.all[index].blurb == nil || self.all[index].blurb == ""
        puts "No reviews found."
    else
        puts self.all[index].blurb.split.join(' ').wrap
    end
    puts ""
    puts "Learn more about #{self.all[index].title} here: #{self.all[index].url}"
    puts ""
    puts "Would you like to learn more about another play? Y/N"
    input = gets.chomp
    if input.downcase == 'y'
        puts ""
        self.list_plays
    end
end
list_plays() click to toggle source
# File lib/prls/pro.rb, line 30
def self.list_plays
    puts ""
    index = 0
    self.all.each do |play|
        puts "#{index + 1}. #{play.title}"
        index += 1
    end
    puts ""
    puts "Which play would you like to learn more about?"
    puts "To return to the PROs menu, type 'pros'."
    puts "To exit, type 'exit'."
    puts ""
    choice = gets.chomp
    if choice.downcase == 'pros'
        PRLS::CLI.session.call
    elsif choice.downcase == 'exit'
        puts 'Exiting...'
        exit
    end
    while choice.to_i > self.all.size + 1
        puts "Invalid entry, please try again."
        choice = gets.chomp
    end
    self.get_details(choice.to_i - 1)
    self.list_details(choice.to_i - 1)
    choice = 0
end
new(attributes) click to toggle source
# File lib/prls/pro.rb, line 5
def initialize(attributes)
    attributes.each do |key, val|
        self.send("#{key}=", val) if self.respond_to?("#{key}=")
    end
end
new_from_scrape(array) click to toggle source
# File lib/prls/pro.rb, line 24
def self.new_from_scrape(array)
    array.each do |data|
        self.new(data)
    end
end

Public Instance Methods

add_attr(hash) click to toggle source
# File lib/prls/pro.rb, line 11
def add_attr(hash)
    hash.each do |key, val|
        self.send("#{key}=", val) if self.respond_to?("#{key}=")
    end
    self
end
need_attr?() click to toggle source
# File lib/prls/pro.rb, line 18
def need_attr?
    if self.instance_variables.size < 5
        true
    end        
end