Sha256: 8763364d46aed95b02657e0d5cf0e7339dfdbd7d84312ac7224115cf1d540769

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# comment.rb
# Copyright (C) RĂ©mi Even 2016
#
# This file is part of Xolti.
#
# Xolti is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Xolti is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Xolti. If not, see <http://www.gnu.org/licenses/>.
def simple_comment(text, comment_token)
	text.lines.map{|line| "#{comment_token}#{line}".rstrip + "\n"}.join
end

def complex_comment(text, comment_tokens)
	result = "#{comment_tokens[0]}\n"
	result << simple_comment(text, comment_tokens[1])
	result << "#{comment_tokens[2]}\n"
	result
end

module Comment
	def Comment.comment(text, comment_tokens)
		comment_tokens.is_a?(String) ? simple_comment(text, comment_tokens) : complex_comment(text, comment_tokens)
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xolti-0.1.1 lib/comment.rb
xolti-0.1.0 lib/comment.rb
xolti-0.0.0 lib/comment.rb