Class: Playtypus::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/playtypus/call.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timestamp, path, verb, headers, body) ⇒ Call

Returns a new instance of Call.



16
17
18
19
20
21
22
# File 'lib/playtypus/call.rb', line 16

def initialize(timestamp, path, verb, headers, body)
  @timestamp = Time.iso8601(timestamp)
  @path = path
  @verb = verb
  @headers = headers
  @body = body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



6
7
8
# File 'lib/playtypus/call.rb', line 6

def body
  @body
end

#headersObject

Returns the value of attribute headers.



6
7
8
# File 'lib/playtypus/call.rb', line 6

def headers
  @headers
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/playtypus/call.rb', line 6

def path
  @path
end

#timestampObject

Returns the value of attribute timestamp.



6
7
8
# File 'lib/playtypus/call.rb', line 6

def timestamp
  @timestamp
end

#verbObject

Returns the value of attribute verb.



6
7
8
# File 'lib/playtypus/call.rb', line 6

def verb
  @verb
end

Class Method Details

.from_hash(hash) ⇒ Object



12
13
14
# File 'lib/playtypus/call.rb', line 12

def self.from_hash(hash)
  return self.new(hash['timestamp'], hash['path'], hash['verb'], hash['headers'], hash['body'])
end

Instance Method Details

#to_hashObject



24
25
26
27
28
29
30
31
32
# File 'lib/playtypus/call.rb', line 24

def to_hash
  {
    'timestamp' => @timestamp,
    'path' => @path,
    'verb' => @verb,
    'headers' => @headers,
    'body' => @body
  }
end

#to_sObject



34
35
36
# File 'lib/playtypus/call.rb', line 34

def to_s
  self.to_hash.to_json
end