Module: Rik::Client::Stream

Included in:
Rik::Client
Defined in:
lib/rik/client/stream.rb

Instance Method Summary collapse

Instance Method Details

#subscribe_follow_streams(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rik/client/stream.rb', line 6

def subscribe_follow_streams(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  
  filter_shared = options[:filter_shared]
  filter_shared = true if filter_shared.nil?
  limit = options[:limit] || 10
  
  begin
    call 'qik.stream.subscribe_follow_streams', create, 
      filter_shared, limit
  
  rescue Rik::API::Error => error
    unless error.fault_code == 2002 
      STDERR << error
      nil
    else # invalid session lets renew
      recreate
      retry
    end
  end
end

#subscribe_own_user_streams(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rik/client/stream.rb', line 28

def subscribe_own_user_streams(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  
  limit = options[:limit] || 10
  
  begin
    call 'qik.stream.subscribe_own_user_streams', create, limit
    
  rescue Rik::API::Error => error
    unless error.fault_code == 2002 
      STDERR << error
      nil
    else # invalid session lets renew
      recreate
      retry
    end
  end
end

#subscribe_public_streams(*args) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rik/client/stream.rb', line 47

def subscribe_public_streams(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  
  recent = options[:recent]
  live = options[:live]
  limit = options[:limit]
  
  begin
    if recent || (!recent && !live)
      call 'qik.stream.subscribe_public_recent', create, limit || 50
    else
      call 'qik.stream.subscribe_public_live', create, limit || 10
    end
    
  rescue Rik::API::Error => error
    unless error.fault_code == 2002 
      STDERR << error
      nil
    else # invalid session lets renew
      recreate
      retry
    end
  end
end

#subscribe_user_streams(*args) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rik/client/stream.rb', line 72

def subscribe_user_streams(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  
  username = args.first
  
  do_public = options[:public] ? '_public' : ''
  limit = options[:limit] || 10
  
  begin
    call "qik.stream.subscribe#{do_public}_user_streams", create, 
      username, limit
      
  rescue Rik::API::Error => error
    unless error.fault_code == 2002 
      STDERR << error
      nil
    else # invalid session lets renew
      recreate
      retry
    end
  end
end