Class: FAFuse::PictureMetadata
- Inherits:
-
Object
- Object
- FAFuse::PictureMetadata
- Defined in:
- lib/fafuse/picture_metadata.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #content ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(path) ⇒ PictureMetadata
constructor
A new instance of PictureMetadata.
- #stat ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ PictureMetadata
Returns a new instance of PictureMetadata.
12 13 14 15 16 |
# File 'lib/fafuse/picture_metadata.rb', line 12 def initialize(path) @id = PictureMetadata.match?(path)[1] @path = path @resource = RestClient::Resource.new("http://www.furaffinity.net/full/") end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/fafuse/picture_metadata.rb', line 6 def id @id end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/fafuse/picture_metadata.rb', line 6 def path @path end |
Class Method Details
.match?(path) ⇒ Boolean
8 9 10 |
# File 'lib/fafuse/picture_metadata.rb', line 8 def self.match?(path) path.match(/^\/[^\.][^\/]+\/gallery\/([^\.][^\/]+)\/metadata.json$/) end |
Instance Method Details
#content ⇒ Object
38 39 40 |
# File 'lib/fafuse/picture_metadata.rb', line 38 def content JSON.generate({ id: @id }) end |
#exists? ⇒ Boolean
32 33 34 35 36 |
# File 'lib/fafuse/picture_metadata.rb', line 32 def exists? Helpers::fa_is_valid?(document) rescue RestClient::NotFound false end |
#stat ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/fafuse/picture_metadata.rb', line 22 def stat RFuse::Stat.file(0444, { :uid => 0, :gid => 0, :atime => Time.now, :mtime => Time.now, :size => content.size }) end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/fafuse/picture_metadata.rb', line 18 def valid? !!id end |