Class: FAFuse::Picture

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Picture

Returns a new instance of Picture.



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

def initialize(path)
  @id = Picture.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.rb', line 6

def id
  @id
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Class Method Details

.match?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#contentObject



38
39
40
41
42
43
44
# File 'lib/fafuse/picture.rb', line 38

def content
  if exists?
    [ "metadata.json", "file#{format}" ]
  else
    raise Errno::ENOENT.new(path)
  end
end

#exists?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/fafuse/picture.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.rb', line 22

def stat
  RFuse::Stat.directory(0555, {
                          :uid => 0,
                          :gid => 0,
                          :atime => Time.now,
                          :mtime => Time.now,
                          :size => 0
                        })
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  !!id
end