Class: Fbwish::Wisher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Wisher

Returns a new instance of Wisher.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fbwish.rb', line 9

def initialize(options={})
  required_options = [:access_token, :matcher, :replies, :wish_count]
  unspecified_options = required_options.reject{ |key| options[key] }

  unless unspecified_options.empty?
    raise ArgumentError, "Following options are required: #{unspecified_options.join(', ')}"
  end

  self.graph = Koala::Facebook::API.new(options[:access_token])
  self.matcher = options[:matcher]
  self.replies = options[:replies]
  self.wish_count = options[:wish_count]
  self.verbose = options[:verbose] || false
end

Instance Attribute Details

#graphObject

Returns the value of attribute graph.



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

def graph
  @graph
end

#matcherObject

Returns the value of attribute matcher.



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

def matcher
  @matcher
end

#repliesObject

Returns the value of attribute replies.



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

def replies
  @replies
end

#verboseObject

Returns the value of attribute verbose.



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

def verbose
  @verbose
end

#wish_countObject

Returns the value of attribute wish_count.



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

def wish_count
  @wish_count
end

Instance Method Details

#should_log?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/fbwish.rb', line 37

def should_log?
  verbose
end

#wish_em_all!Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fbwish.rb', line 24

def wish_em_all!
  wishes = nil
  iteration_count = (wish_count.to_f / 25).ceil

  1.upto(iteration_count) do |idx|
    wishes = wishes.next_page rescue graph.get_connections('me', 'feed')

    wishes.each do |wish|
      like_and_comment(wish)
    end
  end
end