Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

changed message to_s method

  • Loading branch information...
commit e62046bdf514384accb1f7f40ba971c83c66a674 1 parent 0bb3363
Vivek Bhagwat authored

Showing 1 changed file with 16 additions and 4 deletions. Show diff stats Hide diff stats

  1. +16 4 twitter.rb
20 twitter.rb
@@ -4,7 +4,7 @@
4 4 $global_id = 1
5 5
6 6 class Message
7   - attr_accessor :contents, :id, :timestamp
  7 + attr_accessor :contents, :id, :timestamp, :user
8 8
9 9 def initialize(str='', id=0)
10 10 @contents = str
@@ -14,8 +14,12 @@ def initialize(str='', id=0)
14 14 $global_id += 1
15 15 end
16 16
  17 + def to_json
  18 + nil.to_s
  19 + end
  20 +
17 21 def to_s
18   - "Message: " + @contents + " at " + @timestamp
  22 + @contents + " posted at " + @timestamp
19 23 end
20 24 end
21 25
@@ -48,13 +52,21 @@ def to_s
48 52
49 53 get '/post/all' do
50 54 @body = '<h3>All Messages</h3>'
51   - messages.each do |m|
52   - @body += m.to_s
  55 + messages.each do |id, m|
  56 + @body += m.to_s + '<br/>'
53 57 end
54 58
55 59 erb :index
56 60 end
57 61
  62 +get '/posts' do
  63 + redirect('/post/all')
  64 +end
  65 +
  66 +get '/all' do
  67 + redirect('/post/all')
  68 +end
  69 +
58 70 get '/post/:id' do
59 71 id = params[:id].to_s
60 72 @body = "No such message exists"

0 comments on commit e62046b

Please sign in to comment.
Something went wrong with that request. Please try again.