class WhyImBrokeCli::Item

Attributes

info[RW]
location[RW]
title[RW]
type[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/why_im_broke_cli/item.rb, line 15
def self.all
  @@all
end
details(num) click to toggle source
# File lib/why_im_broke_cli/item.rb, line 26
def self.details(num)
  x = all[num]
  puts "\n"
  puts "All you need to know for, #{num + 1}. #{x.title}:"
  puts "\n"
  puts "Type of activity: #{x.type}"
  puts "\n"
  puts "Location: #{x.location}"
  puts "\n"
  puts "Description: #{x.info}"
  puts "\n"
  puts "Website: #{x.url}"
  puts "\n"
end
list() click to toggle source
# File lib/why_im_broke_cli/item.rb, line 19
def self.list
  @@all.each_with_index do |item, i|
    puts "#{i + 1}. #{item.title}"
  end
  nil
end
new(type, title, location, info, url) click to toggle source
# File lib/why_im_broke_cli/item.rb, line 6
def initialize(type, title, location, info, url)
  @type = type
  @title = title
  @location = location
  @info = info
  @url = url
  @@all.push(self) unless @@all.include?(self) || self.title == ""
end
search_by_type(input) click to toggle source
# File lib/why_im_broke_cli/item.rb, line 41
def self.search_by_type(input)
  x = all.select do |item|
    item.type.include?(input)
  end
  x.each_with_index do |item, i|
    puts "#{i + 1}. #{item.title}"
  end
  x
end