Class: Snackhack2::Comments
- Inherits:
-
Object
- Object
- Snackhack2::Comments
- Defined in:
- lib/snackhack2/comments.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize ⇒ Comments
constructor
A new instance of Comments.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Comments
Returns a new instance of Comments.
5 6 7 |
# File 'lib/snackhack2/comments.rb', line 5 def initialize @site = site end |
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
3 4 5 |
# File 'lib/snackhack2/comments.rb', line 3 def site @site end |
Instance Method Details
#run ⇒ Object
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 |