Class: RPaste::PasteBin::Paste
- Inherits:
-
RPaste::Paste
- Object
- RPaste::Paste
- RPaste::PasteBin::Paste
- Defined in:
- lib/rpaste/pastebin/paste.rb
Constant Summary collapse
- PREFIX_URL =
'http://pastebin.com/'
Instance Attribute Summary collapse
-
#retained ⇒ Object
readonly
Time to retain.
Attributes inherited from RPaste::Paste
#author, #date, #name, #syntax, #text
Class Method Summary collapse
-
.paste(name) ⇒ Object
Retrieves the PasteBin Paste object associated with the specified name.
Instance Method Summary collapse
-
#initialize(name = nil, author = nil, date = nil, syntax = nil, retained = nil, text = nil, &block) ⇒ Paste
constructor
Creates a new PasteBin Paste object with the given name, author, date, syntax, retained and text.
-
#url ⇒ Object
Returns the URL of the PasteBin Paste object.
Methods inherited from RPaste::Paste
Constructor Details
#initialize(name = nil, author = nil, date = nil, syntax = nil, retained = nil, text = nil, &block) ⇒ Paste
Creates a new PasteBin Paste object with the given name, author, date, syntax, retained and text. If a block is given, then it will be passed the newly created PasteBin Paste object.
18 19 20 21 22 |
# File 'lib/rpaste/pastebin/paste.rb', line 18 def initialize(name=nil,=nil,date=nil,syntax=nil,retained=nil,text=nil,&block) @retained = retained super(name,,date,syntax,text,&block) end |
Instance Attribute Details
#retained ⇒ Object (readonly)
Time to retain
11 12 13 |
# File 'lib/rpaste/pastebin/paste.rb', line 11 def retained @retained end |
Class Method Details
.paste(name) ⇒ Object
Retrieves the PasteBin Paste object associated with the specified name.
35 36 37 38 39 40 41 42 |
# File 'lib/rpaste/pastebin/paste.rb', line 35 def self.paste(name) page = RPaste.open_page("#{PREFIX_URL}#{name}") return Paste.new(name) do |paste| paste.text = page.search('//div.text/ol/li').inner_text paste. = page.search('#content/h1[1]').inner_text.gsub(/Posted by /,'').split(' on ') end end |
Instance Method Details
#url ⇒ Object
Returns the URL of the PasteBin Paste object.
27 28 29 |
# File 'lib/rpaste/pastebin/paste.rb', line 27 def url "#{PREFIX_URL}#{@name}" end |