Class: PostBin::Post
- Inherits:
-
Object
- Object
- PostBin::Post
- Defined in:
- lib/postbin/post.rb
Overview
Represents header/body information of a HTTP POST request.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#received_at ⇒ Object
readonly
Returns the value of attribute received_at.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Returns true only if the two posts contain equal data.
-
#initialize(headers, body, received_at = nil) ⇒ Post
constructor
A new instance of Post.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(headers, body, received_at = nil) ⇒ Post
Returns a new instance of Post.
7 8 9 10 11 |
# File 'lib/postbin/post.rb', line 7 def initialize(headers, body, received_at = nil) @received_at = received_at || Time.now @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/postbin/post.rb', line 5 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/postbin/post.rb', line 5 def headers @headers end |
#received_at ⇒ Object (readonly)
Returns the value of attribute received_at.
5 6 7 |
# File 'lib/postbin/post.rb', line 5 def received_at @received_at end |
Instance Method Details
#==(other) ⇒ Object
Returns true only if the two posts contain equal data.
14 15 16 17 18 19 |
# File 'lib/postbin/post.rb', line 14 def ==(other) return false unless Post === other return false unless received_at == other.received_at return false unless headers == other.headers body == other.body end |
#to_json(*options) ⇒ Object
21 22 23 |
# File 'lib/postbin/post.rb', line 21 def to_json(*) MultiJson.encode({ :received_at => received_at, :headers => headers, :body => body }) end |