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)
-
- (Object) body
readonly
Returns the value of attribute body.
-
- (Object) headers
readonly
Returns the value of attribute headers.
-
- (Object) received_at
readonly
Returns the value of attribute received_at.
Instance Method Summary (collapse)
-
- (Object) ==(other)
Returns true only if the two posts contain equal data.
-
- (Post) initialize(headers, body, received_at = nil)
constructor
A new instance of Post.
- - (Object) to_json(*a)
Constructor Details
- (Post) initialize(headers, body, received_at = nil)
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
- (Object) body (readonly)
Returns the value of attribute body
5 6 7 |
# File 'lib/postbin/post.rb', line 5 def body @body end |
- (Object) headers (readonly)
Returns the value of attribute headers
5 6 7 |
# File 'lib/postbin/post.rb', line 5 def headers @headers end |
- (Object) received_at (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
- (Object) ==(other)
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 |
- (Object) to_json(*a)
21 22 23 |
# File 'lib/postbin/post.rb', line 21 def to_json(*a) { received_at: received_at, headers: headers, body: body }.to_json(*a) end |