Skip to content

Instantly share code, notes, and snippets.

@mleszcz
Created May 12, 2018 13:57
Show Gist options
  • Save mleszcz/6c1d1d5b9ed2f15708b8c3f0fcb4397b to your computer and use it in GitHub Desktop.
Save mleszcz/6c1d1d5b9ed2f15708b8c3f0fcb4397b to your computer and use it in GitHub Desktop.
class OrderRepor
attr_accessor :attributes
def initialize(various_attributes)
@attributes = various_attributes
end
def print_out
puts "Summary title"
yield @attributes
end
end
report = OrderRepor.new(item_name: "Awesome ebike", total_cost: 2000.0)
report.print_out do |attrs|
puts attrs[:item_name]
end
# Summary title
# Awesome ebike
report.print_out do |attrs|
puts attrs[:item_name]
puts attrs[:total_cost]
end
# Summary title
# Awesome ebike
# 2000.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment