Class: RPaste::NoPaste::ResultSet
- Defined in:
- lib/rpaste/nopaste/result_set.rb,
lib/rpaste/pastebin/result_set.rb
Instance Method Summary collapse
-
#between_ages(start, stop) ⇒ Object
Selects the metadata with ages between start and stop.
-
#between_dates(start, stop) ⇒ Object
Selects the metadata with dates in between start and stop.
-
#each_between_ages(start, stop, &block) ⇒ Object
Iterates over the metadata with ages between start and stop, passing each to the given block.
-
#each_between_dates(start, stop, &block) ⇒ Object
Iterates over the metadata with dates falling in between start and stop, passing each to the given block.
-
#each_paste_between_ages(start, stop, &block) ⇒ Object
Iterates over the pastes with ages between start and stop, passing each to the given block.
-
#each_paste_between_dates(start, stop, &block) ⇒ Object
Iterates over the pastes with dates falling in between start and stop, passing each to the given block.
-
#each_paste_with_description(description, &block) ⇒ Object
Itereates over the pastes with the matching description, passing each to the given block.
-
#each_paste_with_syntax(syntax, &block) ⇒ Object
Iterates over the pastes with the matching syntax, passing each to the given block.
-
#each_paste_with_text(text, &block) ⇒ Object
Iterates over the pastes with the matching text, passing each to the given block.
-
#each_with_description(description, &block) ⇒ Object
Iterates over the metadata with the matching description, passing each to the given block.
-
#each_with_syntax(syntax, &block) ⇒ Object
Iterates over the metadata with the matching syntax, passing each to the given block.
-
#pastes_between_ages(start, stop) ⇒ Object
Returns the pastes with ages between start and stop.
-
#pastes_between_dates(start, stop) ⇒ Object
Returns the pastes with dates falling in between start and stop.
-
#pastes_with_description(description) ⇒ Object
Returns the pastes with the matching description.
-
#pastes_with_syntax(syntax) ⇒ Object
Returns the pastes with the matching syntax.
-
#pastes_with_text(text) ⇒ Object
Returns the pastes with the matching text.
-
#search(desc) ⇒ Object
A symonym for with_description.
-
#with_description(description) ⇒ Object
Selects the metadata containing description.
-
#with_syntax(syntax) ⇒ Object
Selects the metadata with the specified syntax.
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_with_name, #initialize, #paste, #pastes, #pastes_by_author, #pastes_on_date, #pastes_with, #pastes_with_name, #with_name
Constructor Details
This class inherits a constructor from RPaste::ResultSet
Instance Method Details
#between_ages(start, stop) ⇒ Object
Selects the metadata with ages between start and stop.
11 12 13 |
# File 'lib/rpaste/pastebin/result_set.rb', line 11 def between_ages(start,stop) self.select { |data| data.ago.between?(start,stop) } end |
#between_dates(start, stop) ⇒ Object
Selects the metadata with dates in between start and stop.
11 12 13 |
# File 'lib/rpaste/nopaste/result_set.rb', line 11 def between_dates(start,stop) self.select { |data| data.date.between?(start,stop) } end |
#each_between_ages(start, stop, &block) ⇒ Object
Iterates over the metadata with ages between start and stop, passing each to the given block.
19 20 21 |
# File 'lib/rpaste/pastebin/result_set.rb', line 19 def each_between_ages(start,stop,&block) between_ages(start,stop).each(&block) end |
#each_between_dates(start, stop, &block) ⇒ Object
Iterates over the metadata with dates falling in between start and stop, passing each to the given block.
49 50 51 |
# File 'lib/rpaste/nopaste/result_set.rb', line 49 def each_between_dates(start,stop,&block) between_dates(start,stop).each(&block) end |
#each_paste_between_ages(start, stop, &block) ⇒ Object
Iterates over the pastes with ages between start and stop, passing each to the given block.
34 35 36 |
# File 'lib/rpaste/pastebin/result_set.rb', line 34 def each_paste_between_ages(start,stop,&block) pastes_between_ages(start,stop).each(&block) end |
#each_paste_between_dates(start, stop, &block) ⇒ Object
Iterates over the pastes with dates falling in between start and stop, passing each to the given block.
130 131 132 |
# File 'lib/rpaste/nopaste/result_set.rb', line 130 def each_paste_between_dates(start,stop,&block) pastes_between_dates(start,stop).each(&block) end |
#each_paste_with_description(description, &block) ⇒ Object
Itereates over the pastes with the matching description, passing each to the given block.
results.each_paste_with_description('stack') do |paste|
puts paste.text
end
results.each_paste_with_description(/(weird|odd)/) do |paste|
puts paste.text
end
158 159 160 |
# File 'lib/rpaste/nopaste/result_set.rb', line 158 def each_paste_with_description(description,&block) pastes_with_syntax(description).each(&block) end |
#each_paste_with_syntax(syntax, &block) ⇒ Object
Iterates over the pastes with the matching syntax, passing each to the given block.
results.each_paste_with_syntax('Java') do |paste|
puts paste.
end
142 143 144 |
# File 'lib/rpaste/nopaste/result_set.rb', line 142 def each_paste_with_syntax(syntax,&block) pastes_with_syntax(syntax).each(&block) end |
#each_paste_with_text(text, &block) ⇒ Object
Iterates over the pastes with the matching text, passing each to the given block.
results.each_paste_with_text('$_GET') do |paste|
puts paste.text
end
results.each_paste_with_text(/goto/) do |paste|
puts paste.
end
174 175 176 |
# File 'lib/rpaste/nopaste/result_set.rb', line 174 def each_paste_with_text(text,&block) pastes_with_text(text).each(&block) end |
#each_with_description(description, &block) ⇒ Object
Iterates over the metadata with the matching description, passing each to the given block.
results.each_with_description('fizz') do ||
puts .
end
results.each_with_description(/(fi|bu)zz/) do ||
puts .syntax
end
77 78 79 |
# File 'lib/rpaste/nopaste/result_set.rb', line 77 def each_with_description(description,&block) with_description(description).each(&block) end |
#each_with_syntax(syntax, &block) ⇒ Object
Iterates over the metadata with the matching syntax, passing each to the given block.
results.each_with_syntax('ASM') do ||
puts .description
end
61 62 63 |
# File 'lib/rpaste/nopaste/result_set.rb', line 61 def each_with_syntax(syntax,&block) with_syntax(syntax).each(&block) end |
#pastes_between_ages(start, stop) ⇒ Object
Returns the pastes with ages between start and stop.
26 27 28 |
# File 'lib/rpaste/pastebin/result_set.rb', line 26 def pastes_between_ages(start,stop) pastes_with { |data| data.age.between?(start,stop) } end |
#pastes_between_dates(start, stop) ⇒ Object
Returns the pastes with dates falling in between start and stop.
85 86 87 |
# File 'lib/rpaste/nopaste/result_set.rb', line 85 def pastes_between_dates(start,stop) pastes_with { |data| data.date.between?(start,stop) } end |
#pastes_with_description(description) ⇒ Object
Returns the pastes with the matching description.
results.pastes_with_description('error')
results.pastes_with_description(/\d+(\.\d+)+/)
104 105 106 107 108 109 110 |
# File 'lib/rpaste/nopaste/result_set.rb', line 104 def pastes_with_description(description) if description.kind_of?(Regexp) return pastes_with { |data| data.description =~ description } else return pastes_with { |data| data.description.include?(description) } end end |
#pastes_with_syntax(syntax) ⇒ Object
Returns the pastes with the matching syntax.
results.pastes_with_syntax('Javascript')
94 95 96 |
# File 'lib/rpaste/nopaste/result_set.rb', line 94 def pastes_with_syntax(syntax) pastes_with { |data| data.syntax == syntax } end |
#pastes_with_text(text) ⇒ Object
Returns the pastes with the matching text.
results.pastes_with_text('strcpy')
results.pastes_with_text(/printf\([^\",]+,/)
118 119 120 121 122 123 124 |
# File 'lib/rpaste/nopaste/result_set.rb', line 118 def pastes_with_text(text) if text.kind_of?(Regexp) return pastes_with { |data| data.text =~ text } else return pastes_with { |data| data.text.include?(text) } end end |
#search(desc) ⇒ Object
A symonym for with_description.
41 42 43 |
# File 'lib/rpaste/nopaste/result_set.rb', line 41 def search(desc) with_description(desc) end |
#with_description(description) ⇒ Object
Selects the metadata containing description.
results.with_description('hello world')
results.with_description(/(form|reg)/)
30 31 32 33 34 35 36 |
# File 'lib/rpaste/nopaste/result_set.rb', line 30 def with_description(description) if description.kind_of?(Regexp) return self.select { |data| data.description =~ description } else return self.select { |data| data.description.include?(description) } end end |
#with_syntax(syntax) ⇒ Object
Selects the metadata with the specified syntax.
results.with_syntax('PHP')
20 21 22 |
# File 'lib/rpaste/nopaste/result_set.rb', line 20 def with_syntax(syntax) self.select { |data| data.syntax == syntax } end |