Class: Safran::Parser
- Inherits:
-
Object
- Object
- Safran::Parser
- Defined in:
- lib/safran/parser.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
- #print(item) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
9 10 11 |
# File 'lib/safran/parser.rb', line 9 def initialize @url = 'http://www.safran.io/feed.rss' end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/safran/parser.rb', line 7 def url @url end |
Instance Method Details
#parse ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/safran/parser.rb', line 13 def parse begin open(@url) do |rss| feed = RSS::Parser.parse(rss) feed.items.each do |item| print item end end rescue => e "Bir hata oluştu: #{e}" end end |
#print(item) ⇒ Object
26 27 28 29 30 |
# File 'lib/safran/parser.rb', line 26 def print(item) puts "#{item.title}".colorize(:red) puts "#{item.link}".colorize(:blue).underline puts '' end |