これはひどい
同僚がネットカフェの会員証をもらってきたそうです。
樹さんの微妙な日常
def set_view
template = get_template #これで、ビューのテンプレートを取得する(ものとして下さい)
my_tags = ['<!-- do_something -->',
'<!-- show_something -->',
'<!-- play_something -->']
my_tags.each {|tag|
template.gsub(tag, convert(tag))
}
end
private
def convert(tag) #タグを変換、実行
case tag #実際の処理はタグによって異なる
when '<!-- do_something -->'
do_something
when '<!-- show_something -->'
show_something
when '<!-- play_something -->'
play_something
end
end
def get_topic_path(ary = []) #Categoryクラスに定義
ary.unshift(self)
if self.parent_id.nil?
return ary
else
Category.find(self.parent_id).get_topic_path(ary)
end
end
def get_tree_list #木構造でリスト作成
children = Category.find_by_parent_id(self.id)
unless children.blank?
self.categories = children
children.each {|child|
child.get_tree_list
}
end
end