Class: FAFuse::UserMetadata
- Inherits:
-
Object
- Object
- FAFuse::UserMetadata
- Defined in:
- lib/fafuse/user_metadata.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) ⇒ UserMetadata
constructor
A new instance of UserMetadata.
- #stat ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ UserMetadata
Returns a new instance of UserMetadata.
13 14 15 16 17 |
# File 'lib/fafuse/user_metadata.rb', line 13 def initialize(path) @path = path @slug = UserMetadata.match?(path)[1] @resource = RestClient::Resource.new("http://www.furaffinity.net/user/") end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/fafuse/user_metadata.rb', line 7 def path @path end |
#slug ⇒ Object
Returns the value of attribute slug.
7 8 9 |
# File 'lib/fafuse/user_metadata.rb', line 7 def slug @slug end |
Class Method Details
.match?(path) ⇒ Boolean
9 10 11 |
# File 'lib/fafuse/user_metadata.rb', line 9 def self.match?(path) path.match(/^\/([^\.][^\/]+)\/metadata.json$/) end |
Instance Method Details
#content ⇒ Object
37 38 39 |
# File 'lib/fafuse/user_metadata.rb', line 37 def content JSON.generate({ slug: slug }) end |
#exists? ⇒ Boolean
33 34 35 |
# File 'lib/fafuse/user_metadata.rb', line 33 def exists? Helpers::fa_is_valid?(document) end |
#stat ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/fafuse/user_metadata.rb', line 23 def stat return RFuse::Stat.file(0444, { :uid => 0, :gid => 0, :atime => Time.now, :mtime => Time.now, :size => content.size }) end |
#valid? ⇒ Boolean
19 20 21 |
# File 'lib/fafuse/user_metadata.rb', line 19 def valid? !!slug && slug[0] != "." end |