Skip to content
seamusabshere edited this page Jun 27, 2012 · 3 revisions
  • maybe tail should return a File object and you can do a read() on it to get source or path() on it to get path
  • yah i mean you could just have all the commands return an instance of a special kind of object that responds to #to_path, #to_s, and delegates all other methods to one or the other (whichever makes more sense)
  • (you could also provide a #destructively method via closure that deletes that shit)
  • i.e. UnixUtils.untar('fo.tar').destructively.to_s
  • yah i mean for legacy reasons you could delegate other methods to #to_path, since that's basically what you're using now
  • but you could also have #to_file (File.open(to_path))
  • #to_io
  • whatever
  • you could also pretty easily support composition
  • UnixUtils.untar('fo.tar').destructively.tail
  • essentially, if the delegatable method is a recognized UnixUtils command, you just spawn it with the previous result as the new param
  • since the result of every command is an instance of your special delegator class, you stay closed under composition, to the extent you want to

Clone this wiki locally