class FaceGroups::Runner

Executable code for file(s) in bin/ folder

Public Class Methods

attachment_output(attachment) click to toggle source
# File lib/facegroups/runner.rb, line 41
def self.attachment_output(attachment)
  attachment ? attachment.url.to_s : '(none)'
end
message_output(message) click to toggle source
# File lib/facegroups/runner.rb, line 37
def self.message_output(message)
  message ? message : '(blank)'
end
output_info(group) click to toggle source
# File lib/facegroups/runner.rb, line 18
def self.output_info(group)
  name = group.name
  separator = Array.new(group.name.length) { '-' }.join
  group_info = group.feed.postings.first(3).map.with_index do |post, index|
    posting_info(post, index)
  end.join

  [name, separator, group_info].join("\n")
end
posting_info(post, index) click to toggle source
# File lib/facegroups/runner.rb, line 28
def self.posting_info(post, index)
  [
    "#{index + 1}: ",
    message_output(post.message),
    'Attached: ' + attachment_output(post.attachment),
    "\n\n"
  ].join
end
run!(args) click to toggle source
# File lib/facegroups/runner.rb, line 6
def self.run!(args)
  group_id = args[0] || ENV['FB_GROUP_ID']
  unless group_id
    puts 'USAGE: facegroups [group_id]'
    exit(1)
  end

  group = FaceGroups::Group.find(id: group_id)

  output_info(group)
end