Class: Pili::StreamInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/pili/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hub, key, disabled_till) ⇒ StreamInfo

Returns a new instance of StreamInfo.



12
13
14
15
16
# File 'lib/pili/stream.rb', line 12

def initialize(hub, key, disabled_till)
  @hub = hub
  @key = key
  @disabled_till = disabled_till
end

Instance Attribute Details

#disabled_tillObject (readonly)

表示禁用结束的时间, 0 表示不禁用, -1 表示永久禁用.



10
11
12
# File 'lib/pili/stream.rb', line 10

def disabled_till
  @disabled_till
end

#hubObject (readonly)

Returns the value of attribute hub.



7
8
9
# File 'lib/pili/stream.rb', line 7

def hub
  @hub
end

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/pili/stream.rb', line 7

def key
  @key
end

Instance Method Details

#disabled?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/pili/stream.rb', line 18

def disabled?
  @disabled_till == -1 || @disabled_till > Time.new.to_i
end

#to_jsonObject



26
27
28
# File 'lib/pili/stream.rb', line 26

def to_json
  {:hub=>@hub, :key=>@key, :disabled=>disabled?}.to_json
end

#to_sObject



22
23
24
# File 'lib/pili/stream.rb', line 22

def to_s
  "#<#{self.class} #{@hub}/#{@key} disabled:#{disabled?}>"
end