Module: Concerns::Printable
- Included in:
- PriceManager
- Defined in:
- lib/concerns/concerns.rb
Instance Method Summary collapse
- #print_basic_stats ⇒ Object
- #print_item_by_pid ⇒ Object
- #print_items_by_price ⇒ Object
- #print_items_in_category ⇒ Object
- #print_items_in_range ⇒ Object
Instance Method Details
#print_basic_stats ⇒ Object
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 |
#print_item_by_pid ⇒ Object
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 |
#print_items_by_price ⇒ Object
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 |
#print_items_in_category ⇒ Object
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 |
#print_items_in_range ⇒ Object
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 |