Class: RPaste::NoPaste::Recent
- Defined in:
- lib/rpaste/nopaste/recent.rb
Constant Summary collapse
- URL =
'http://www.rafb.net/paste/results.html'
Class Method Summary collapse
-
.get(opts = {}, &block) ⇒ Object
Returns the list of recent pastes on NoPaste.
Methods inherited from ResultSet
#by_author, #clear, #each_by_author, #each_paste, #each_paste_by_author, #each_paste_on_date, #each_paste_with_name, #each_paste_with_syntax, #each_paste_with_text, #each_with_name, #initialize, #paste, #pastes, #pastes_by_author, #pastes_on_date, #pastes_with, #pastes_with_name, #pastes_with_syntax, #pastes_with_text, #with_name
Constructor Details
This class inherits a constructor from RPaste::ResultSet
Class Method Details
.get(opts = {}, &block) ⇒ Object
Returns the list of recent pastes on NoPaste. If opts are given they will be used in accessing the NoPaste website. If a block is given, it will be passed the list of recent pastes.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rpaste/nopaste/recent.rb', line 17 def self.get(opts={},&block) len = opts[:length] if len.nil? || len==0 len = -1 else len = len.to_i+1 end page = Hpricot(RPaste.open(URL,opts)) rows = page.search('//div.filelist/table/tr')[1..len] = rows.map do |row| name = row.search('td[4]/a').first.get_attribute('href').gsub(/^.*\//,'').gsub(/\..*$/,'') date = row.search('td[1]').inner_text syntax = row.search('td[2]').inner_text = row.search('td[3]').inner_text description = row.search('td[4]/a').inner_text Metadata.new(name,,date,syntax,description) end new_recent = self.new() block.call(new_recent) if block return new_recent end |