 Workouts.prototype.getAllMeta = () ->
 	this._meta.getAll()
 
+Workouts.prototype.renderMeta = () ->
+	this._meta.render()
+
 WorkoutsMeta = (textChunks) ->
 	this._meta = []
 	this

WorkoutsMeta.prototype.getAll = () ->
	this._meta.slice()

Workout = (workoutText) ->
	this._chunks = workoutText.split('\n')
	this._header = new WorkoutHeader(this._chunks[0])

Workout.prototype.isValid = () ->
	this._header.isValid()

Workout.prototype.render = () ->
	'<div class="workout">' +
		this._header.render() +
		this._exercises.join('') +
	'</div>'

WorkoutHeader = (headerText) ->
	DATE_REGEXP = /^(\d+\/\d+\/\d+)\s/
	this._text = headerText
	this._workoutDate = headerText.match(DATE_REGEXP)?[1]
	this

WorkoutHeader.prototype.isValid = () ->
	!!this._workoutDate

WorkoutHeader.prototype.render = () ->
	'<div class="workout-header">' +
		this._text +
	'</div>'

Exercises = (exercises) -> this

WorkoutsView = (workouts) ->
	html = []

	html.push workouts.renderMeta()

	html.push workouts.getAll().map (workout) ->
		workout.render()

	this._html = html.join('')
	this
