Class: RPaste::NoPaste::Paste
- Defined in:
- lib/rpaste/nopaste/paste.rb
Constant Summary collapse
- PREFIX_URL =
'http://rafb.net/p/'
Instance Attribute Summary collapse
-
#description ⇒ Object
Description of the entry.
Attributes inherited from Paste
#author, #date, #name, #syntax, #text
Class Method Summary collapse
-
.paste(name) ⇒ Object
Retrieves the NoPaste Paste object associated with the specified name.
Instance Method Summary collapse
-
#initialize(name = nil, author = nil, date = nil, syntax = nil, description = nil, text = nil, &block) ⇒ Paste
constructor
Creates a new NoPaste Paste object with the given name, author, date, syntax, description and text.
-
#url ⇒ Object
Returns the URL of the NoPaste Paste object.
Methods inherited from Paste
Constructor Details
#initialize(name = nil, author = nil, date = nil, syntax = nil, description = nil, text = nil, &block) ⇒ Paste
Creates a new NoPaste Paste object with the given name, author, date, syntax, description and text.
19 20 21 22 23 |
# File 'lib/rpaste/nopaste/paste.rb', line 19 def initialize(name=nil,=nil,date=nil,syntax=nil,description=nil,text=nil,&block) @description = description super(name,,date,syntax,text,&block) end |
Instance Attribute Details
#description ⇒ Object
Description of the entry
13 14 15 |
# File 'lib/rpaste/nopaste/paste.rb', line 13 def description @description end |
Class Method Details
.paste(name) ⇒ Object
Retrieves the NoPaste Paste object associated with the specified name.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rpaste/nopaste/paste.rb', line 36 def self.paste(name) page = RPaste.open_page("#{PREFIX_URL}#{name}.html") return Paste.new(name) do |paste| paste.syntax = page.search('//table[1]/tr[1]/td/small/b[1]').inner_text paste. = page.search('//table[1]/tr[1]/td/small/b[2]').inner_text paste.description = page.search('//table[1]/tr[2]/td/small').inner_text.gsub(/^Description: /,'') paste.text = page.search('#codemain').inner_text end end |
Instance Method Details
#url ⇒ Object
Returns the URL of the NoPaste Paste object.
28 29 30 |
# File 'lib/rpaste/nopaste/paste.rb', line 28 def url "#{PREFIX_URL}#{@name}.html" end |