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.
7 8 9 |
# File 'lib/snackhack2/comments.rb', line 7 def initialize @site = site end |
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
5 6 7 |
# File 'lib/snackhack2/comments.rb', line 5 def site @site end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/snackhack2/comments.rb', line 11 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 elsif line.include?('<!') puts body[i].next end end else puts "Status Code: #{c.code}\n" end end |