Class: FAFuse::PictureFile

Inherits:
Object
  • Object
show all
Defined in:
lib/fafuse/picture_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PictureFile

Returns a new instance of PictureFile.



12
13
14
15
16
# File 'lib/fafuse/picture_file.rb', line 12

def initialize(path)
  @id = PictureFile.match?(path)[1]
  @path = path
  @resource = RestClient::Resource.new("http://www.furaffinity.net/full/")
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/fafuse/picture_file.rb', line 6

def id
  @id
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/fafuse/picture_file.rb', line 6

def path
  @path
end

Class Method Details

.match?(path) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/fafuse/picture_file.rb', line 8

def self.match?(path)
  path.match(/^\/[^\.][^\/]+\/gallery\/([^\.][^\/]+)\/file\.[^\/]+$/)
end

Instance Method Details

#contentObject



38
39
40
# File 'lib/fafuse/picture_file.rb', line 38

def content
  RestClient.get(document.css("#submissionImg").first["src"].gsub(/^\/\//, "http://")).body
end

#exists?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/fafuse/picture_file.rb', line 32

def exists?
  Helpers::fa_is_valid?(document)
rescue RestClient::NotFound
  false
end

#statObject



22
23
24
25
26
27
28
29
30
# File 'lib/fafuse/picture_file.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

Returns:

  • (Boolean)


18
19
20
# File 'lib/fafuse/picture_file.rb', line 18

def valid?
  !!id
end