Class: FAFuse::Gallery
- Inherits:
-
Object
- Object
- FAFuse::Gallery
- Defined in:
- lib/fafuse/gallery.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#slug ⇒ Object
Returns the value of attribute slug.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(path) ⇒ Gallery
constructor
A new instance of Gallery.
- #stat ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/fafuse/gallery.rb', line 6 def path @path end |
#slug ⇒ Object
Returns the value of attribute slug.
6 7 8 |
# File 'lib/fafuse/gallery.rb', line 6 def slug @slug end |
Class Method Details
.match?(path) ⇒ Boolean
8 9 10 |
# File 'lib/fafuse/gallery.rb', line 8 def self.match?(path) path.match(/^\/([^\.][^\/]+)\/gallery$/) end |
Instance Method Details
#content ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fafuse/gallery.rb', line 36 def content [].tap do |content| loop.with_index do |_, page| @gallery = Nokogiri::HTML(@resource[slug][page + 1].get.body) break if @gallery.text.include?("There are no submissions to list") pictures = @gallery.css("#gallery-gallery figcaption a").map do |link| if link['href'].match(/^\/view\/.+\/$/) link['href'].match(/^\/view\/(.+)\/$/)[1] end end.compact content.concat pictures end end end |
#exists? ⇒ Boolean
32 33 34 |
# File 'lib/fafuse/gallery.rb', line 32 def exists? Helpers::fa_is_valid?(document) end |
#stat ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/fafuse/gallery.rb', line 22 def stat return RFuse::Stat.directory(0555, { :uid => 0, :gid => 0, :atime => Time.now, :mtime => Time.now, :size => 0 }) end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/fafuse/gallery.rb', line 18 def valid? !!slug && slug[0] != "." end |