Module: Concerns::Printable

Included in:
PriceManager
Defined in:
lib/concerns/concerns.rb

Instance Method Summary collapse

Instance Method Details



71
72
73
# File 'lib/concerns/concerns.rb', line 71

def print_basic_stats
  basic_stats{items_with_price}.each_pair{|key,val| puts "#{key} is #{val}"}
end


66
67
68
69
# File 'lib/concerns/concerns.rb', line 66

def print_item_by_pid
  item = search_by_pid
  item.instance_variables.each{|var| puts "#{var.to_s.gsub(/@/,"")}: #{item.instance_variable_get(var)}"} #We cannot know ahead of time which attributes will be populated!
end


62
63
64
# File 'lib/concerns/concerns.rb', line 62

def print_items_by_price
  sort_by_price.each{|item| puts "pid: #{item.pid} :#{item.title} $#{item.price}"}
end


57
58
59
60
# File 'lib/concerns/concerns.rb', line 57

def print_items_in_category
  search_by_category.each{|item| puts "pid: #{item.pid} :#{item.title} $#{item.price}"}
  puts "There are a total of #{search_by_category.length} items in #{@category}"
end


75
76
77
78
79
# File 'lib/concerns/concerns.rb', line 75

def print_items_in_range
  sort_by_price_in_range.each{|item| puts "pid: #{item.pid} :#{item.title} $#{item.price}"}
  puts "#{items_in_price_range.length} #{@item} found in #{@category} between $#{@min} and $#{@max}"
  basic_stats{items_in_price_range}.each_pair{|key,val| puts "#{key} is #{val}"}
end