public
Created

  • Download Gist
post.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class Post
def initialize(params)
@params = params
end
 
def safe_title
make_safe @params[:title]
end
 
def make_safe(str)
str.gsub(/[^\w]/, '-')
end
end
 
new_post = Post.new('title' => 'new post', 'body' => 'your text here')
puts new_post.safe_title

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.