Class: Snackhack2::Comments

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeComments

Returns a new instance of Comments.



5
6
7
# File 'lib/snackhack2/comments.rb', line 5

def initialize
  @site = site
end

Instance Attribute Details

#siteObject

Returns the value of attribute site.



3
4
5
# File 'lib/snackhack2/comments.rb', line 3

def site
  @site
end

Instance Method Details

#runObject



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

def run
  c = Snackhack2::get(@site)

  if c.code == 200
    body = c.body.split("\n")
    body.each_with_index do |l, i|
      line = l.strip
      if line.start_with?("<!--")
        puts body[i].next
      end
    end
  else
    puts "Status Code: #{c.code}\n"
  end
end