Skip to content

Instantly share code, notes, and snippets.

@dgorodnichy
Created October 26, 2021 07:49
Show Gist options
  • Save dgorodnichy/6c66bd53c052995763b79a0112350d2a to your computer and use it in GitHub Desktop.
Save dgorodnichy/6c66bd53c052995763b79a0112350d2a to your computer and use it in GitHub Desktop.
ViewObject example
class DateViewObject
attr_reader :date
def initialize(date)
@date = date
end
def us
date.strftime('%m/%d/%y')
end
def uk
date.strftime('%d/%m/%y')
end
end
date = DateViewObject.new(DateTime.now)
date.uk # => "24/10/21"
date.us # => "10/24/21"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment