Sha256: 5d64d7e1dd0e16996b3d70927875ef54b8d099076b89b96997749e27996481ec
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
module Spectate class Status include Encode attr_reader :server, :source def initialize(server, source, properties = {}) @server, @source = server, source @status = properties.inject({}) do |status, (key, value)| # Shamelessly lifted from ActiveSupport status[(key.to_sym rescue key) || key] = value status end end # An array of all the properties contained in this Status object. def properties @status.keys end # Returns the path of the spectator that owns this source. In practical # terms, this simply truncates to the next-to-last element on the path; so # if the source is '/examples/foo/re_bar' the parent would be # '/examples/foo'. def parent @source.slice %r{^/.*(?=/)} end # The English representation of the name of the spectator belonging to this source. def name decode @source.slice(%r{/[^/]+$}).delete('/') # Ruby 1.8 doesn't support lookbehind end def [](key) @status[key] end def method_missing(method, *args, &block) if @status.has_key?(method) @status[method] else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spectate-0.0.0 | lib/spectate/status.rb |