Class: RPaste::Paste
- Inherits:
-
Object
- Object
- RPaste::Paste
- Defined in:
- lib/rpaste/paste.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#author ⇒ Object
Author of the entry.
-
#date ⇒ Object
Date of the entry.
-
#name ⇒ Object
Name of the entry.
-
#syntax ⇒ Object
Syntax of the entry text.
-
#text ⇒ Object
Text of the entry.
Instance Method Summary collapse
-
#initialize(name = nil, author = nil, date = nil, syntax = nil, text = nil, &block) ⇒ Paste
constructor
Creates a new Paste object with the optional name, author, date, syntax and text.
-
#to_a ⇒ Object
Returns an array containing the text lines of the paste.
-
#to_s ⇒ Object
Returns a string containing the text of the paste.
Constructor Details
#initialize(name = nil, author = nil, date = nil, syntax = nil, text = nil, &block) ⇒ Paste
Creates a new Paste object with the optional name, author, date, syntax and text. If a block is given, then it will be passed the newly created Paste object.
24 25 26 27 28 29 30 31 32 |
# File 'lib/rpaste/paste.rb', line 24 def initialize(name=nil,=nil,date=nil,syntax=nil,text=nil,&block) @name = name @author = @date = Time.parse(date) if date @syntax = syntax @text = text block.call(self) if block end |
Instance Attribute Details
#author ⇒ Object
Author of the entry
8 9 10 |
# File 'lib/rpaste/paste.rb', line 8 def @author end |
#date ⇒ Object
Date of the entry
11 12 13 |
# File 'lib/rpaste/paste.rb', line 11 def date @date end |
#name ⇒ Object
Name of the entry
5 6 7 |
# File 'lib/rpaste/paste.rb', line 5 def name @name end |
#syntax ⇒ Object
Syntax of the entry text
14 15 16 |
# File 'lib/rpaste/paste.rb', line 14 def syntax @syntax end |
#text ⇒ Object
Text of the entry
17 18 19 |
# File 'lib/rpaste/paste.rb', line 17 def text @text end |
Instance Method Details
#to_a ⇒ Object
Returns an array containing the text lines of the paste.
44 45 46 |
# File 'lib/rpaste/paste.rb', line 44 def to_a self.to_s.split end |
#to_s ⇒ Object
Returns a string containing the text of the paste.
37 38 39 |
# File 'lib/rpaste/paste.rb', line 37 def to_s @text.to_s end |