Class: PRLS::CLI::PRO
- Inherits:
-
Object
- Object
- PRLS::CLI::PRO
- Defined in:
- lib/prls/pro.rb
Direct Known Subclasses
BPP, CONCORD, DPS, MTI, PLAYSCRIPTS
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#blurb ⇒ Object
Returns the value of attribute blurb.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #add_attr(hash) ⇒ Object
-
#initialize(attributes) ⇒ PRO
constructor
A new instance of PRO.
- #need_attr? ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ PRO
Returns a new instance of PRO.
5 6 7 8 9 |
# 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 |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/prls/pro.rb', line 3 def end |
#blurb ⇒ Object
Returns the value of attribute blurb.
3 4 5 |
# File 'lib/prls/pro.rb', line 3 def blurb @blurb end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/prls/pro.rb', line 3 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/prls/pro.rb', line 3 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/prls/pro.rb', line 3 def url @url end |
Class Method Details
.list_details(index) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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 ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# 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_from_scrape(array) ⇒ Object
24 25 26 27 28 |
# File 'lib/prls/pro.rb', line 24 def self.new_from_scrape(array) array.each do |data| self.new(data) end end |
Instance Method Details
#add_attr(hash) ⇒ Object
11 12 13 14 15 16 |
# 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? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/prls/pro.rb', line 18 def need_attr? if self.instance_variables.size < 5 true end end |