Class: Wurk::ProfileRecord
- Inherits:
-
Object
- Object
- Wurk::ProfileRecord
- Defined in:
- lib/wurk/profile_set.rb
Overview
One profile record: the metadata fields of a ‘<token>-<jid>` HASH plus lazy access to the gzipped gecko blob. Spec §19.8.
Instance Attribute Summary collapse
-
#elapsed ⇒ Object
readonly
Returns the value of attribute elapsed.
-
#jid ⇒ Object
readonly
Returns the value of attribute jid.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#data ⇒ Object
The stored blob is gzipped gecko JSON.
-
#initialize(hash) ⇒ ProfileRecord
constructor
A new instance of ProfileRecord.
- #key ⇒ Object
- #started_at ⇒ Object
Constructor Details
#initialize(hash) ⇒ ProfileRecord
Returns a new instance of ProfileRecord.
42 43 44 45 46 47 48 49 |
# File 'lib/wurk/profile_set.rb', line 42 def initialize(hash) @hash = hash @jid = hash['jid'] @type = hash['type'] @token = hash['token'] @size = hash['size'].to_i @elapsed = hash['elapsed'].to_i end |
Instance Attribute Details
#elapsed ⇒ Object (readonly)
Returns the value of attribute elapsed.
40 41 42 |
# File 'lib/wurk/profile_set.rb', line 40 def elapsed @elapsed end |
#jid ⇒ Object (readonly)
Returns the value of attribute jid.
40 41 42 |
# File 'lib/wurk/profile_set.rb', line 40 def jid @jid end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
40 41 42 |
# File 'lib/wurk/profile_set.rb', line 40 def size @size end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
40 41 42 |
# File 'lib/wurk/profile_set.rb', line 40 def token @token end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
40 41 42 |
# File 'lib/wurk/profile_set.rb', line 40 def type @type end |
Instance Method Details
#data ⇒ Object
The stored blob is gzipped gecko JSON. ‘data` returns the raw (gzipped) bytes — the web layer streams them straight to the browser with a gzip Content-Encoding. Returns nil if the HASH expired between list and read.
61 62 63 |
# File 'lib/wurk/profile_set.rb', line 61 def data Wurk.redis { |conn| conn.call('HGET', key, 'data') } end |
#key ⇒ Object
56 |
# File 'lib/wurk/profile_set.rb', line 56 def key = Wurk::Profiler.profile_key(@token, @jid) |
#started_at ⇒ Object
51 52 53 54 |
# File 'lib/wurk/profile_set.rb', line 51 def started_at ts = @hash['started_at'] ::Time.at(ts.to_i) unless ts.nil? || ts.empty? end |