Class: SO_Comment_Hellban::Hellban

Inherits:
Object
  • Object
show all
Defined in:
lib/so-comment-hellban.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(declined_flags, helpful_flags) ⇒ Hellban

Returns a new instance of Hellban.



54
55
56
57
58
# File 'lib/so-comment-hellban.rb', line 54

def initialize(declined_flags, helpful_flags)
  @declined_flags, @helpful_flags = 
    declined_flags.to_i, helpful_flags.to_i
  get_counts unless @declined_flags and @helpful_flags
end

Instance Attribute Details

#declined_flagsObject (readonly)

Returns the value of attribute declined_flags.



52
53
54
# File 'lib/so-comment-hellban.rb', line 52

def declined_flags
  @declined_flags
end

#helpful_flagsObject (readonly)

Returns the value of attribute helpful_flags.



52
53
54
# File 'lib/so-comment-hellban.rb', line 52

def helpful_flags
  @helpful_flags
end

Class Method Details

.usageObject



76
77
78
79
# File 'lib/so-comment-hellban.rb', line 76

def self.usage
  warn "Usage: #{File.basename $0} <declined_flags> <helpful_flags>"
  exit 64
end

.valid_args?Boolean

Returns:

  • (Boolean)


81
82
83
84
# File 'lib/so-comment-hellban.rb', line 81

def self.valid_args?
  ARGV.size == 2 and
  ARGV.all? {|arg| arg.to_s =~ /^\d+$/ }
end

Instance Method Details

#reportObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/so-comment-hellban.rb', line 60

def report
  puts '# Stack Overflow Comment-Hellban Calculator'
  puts
  puts  "  - Current Flag Weight: #{flag_weight}"
  print '  - Hellban Status: '

  if comment_hellbanned?
    puts 'You are hellbanned.'
    puts
    puts 'See http://meta.stackoverflow.com/questions/82445/comment-hellban'
    puts 'for more information.'
  else
    puts "You aren't banned...yet."
  end
end