<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def metadata(self):
 """Return dict representation of this cookbook's metadata.rb ."""

        self.metadata_path = os.path.join(self.path, 'metadata.rb')
        if not os.path.isfile(self.metadata_path):
            raise ValueError("Cookbook needs metadata.rb, %s"
                             % self.metadata_path)

        if not self._metadata:
            self._metadata = MetadataRb(open(self.metadata_path, 'r+'))

        return self._metadata